Example #1
0
EC_API ec_list ec_list_remove( ec_list list, ec_list_node node )
{
	ec_list_node prev, cur;

	check_list(list);
	check_node(node);
	if (! node) return list;

	prev = NULL;
	cur  = HEAD(list);
	while (cur && (cur != node))
	{
		prev = cur;
		cur  = NEXT(cur);
	}

	if (cur != node) return list;

	ASSERT( cur && (cur == node) );

	if (prev)
		NEXT(prev) = NEXT(node);
	else
		HEAD(list) = NEXT(node);
	NEXT(node) = NULL;

	check_list(list);
	return list;
}
Example #2
0
EC_API ec_list ec_list_copy( ec_list list )
{
	ec_list          newlist;
	ec_list_iterator iter;
	ec_list_node     node, newnode, last;

	check_list(list);

	newlist = ec_list_create();
	if (! newlist) return NULL;

	last = NULL;
	iter = ec_list_iterator_create( list );
	while ((node = ec_list_iterator_next( iter )))
	{
		check_node(node);
		newnode = alloc_node( KEY(node), DATA(node) );
		ASSERT( newnode );
		if (! newnode) return NULL;								/* argh ! */
		if (last)
			NEXT(last) = newnode;
		else
		{
			HEAD(newlist) = newnode;
			last          = newnode;
		}
	}
	ec_list_iterator_destroy( iter );

	check_list(newlist);
	return newlist;
}
Example #3
0
File: relay.c Project: AndreRH/wine
/***********************************************************************
 *           RELAY_ShowDebugmsgRelay
 *
 * Simple function to decide if a particular debugging message is
 * wanted.
 */
static BOOL RELAY_ShowDebugmsgRelay(const char *module, int ordinal, const char *func)
{
    if (debug_relay_excludelist && check_list( module, ordinal, func, debug_relay_excludelist ))
        return FALSE;
    if (debug_relay_includelist && !check_list( module, ordinal, func, debug_relay_includelist ))
        return FALSE;
    return TRUE;
}
Example #4
0
File: relay.c Project: AndreRH/wine
/***********************************************************************
 *          SNOOP16_ShowDebugmsgSnoop
 *
 * Simple function to decide if a particular debugging message is
 * wanted.
 */
BOOL SNOOP16_ShowDebugmsgSnoop(const char *module, int ordinal, const char *func)
{
    if (debug_snoop_excludelist && check_list( module, ordinal, func, debug_snoop_excludelist ))
        return FALSE;
    if (debug_snoop_includelist && !check_list( module, ordinal, func, debug_snoop_includelist ))
        return FALSE;
    return TRUE;
}
Example #5
0
int run_tests()
{
    /* assumes that the test directory has been set up and we have
       changed into the test directory. */

    check_list("*", dir_entries, n_dir_entries + 2, 1);
    check_list("*.*", dir_entries, n_dir_entries + 2, 1);
    check_list("C*", entries_begin_with_C, sizeof(entries_begin_with_C)/sizeof(entries_begin_with_C[0]), 0);
    check_list("*A", entries_end_with_A, sizeof(entries_end_with_A)/sizeof(entries_end_with_A[0]), 0);

    return 0;
}
Example #6
0
static int		check_tree(struct memtree	*tree)
{
  if (tree == NULL)
    return (0);
  int			i;

  i = check_list(tree->allocated);
  i += check_list(tree->freed);
  i += check_tree(tree->lesser);
  i += check_tree(tree->greater);
  return (i);
}
Example #7
0
static int
name_convert(krb5_context context, const char *name, const char *realm, 
	     const char **out)
{
    const krb5_config_binding *l;
    l = krb5_config_get_list (context,
			      NULL,
			      "realms",
			      realm,
			      "v4_name_convert",
			      "host",
			      NULL);
    if(l && check_list(l, name, out))
	return KRB5_NT_SRV_HST;
    l = krb5_config_get_list (context,
			      NULL,
			      "libdefaults",
			      "v4_name_convert",
			      "host",
			      NULL);
    if(l && check_list(l, name, out))
	return KRB5_NT_SRV_HST;
    l = krb5_config_get_list (context,
			      NULL,
			      "realms",
			      realm,
			      "v4_name_convert",
			      "plain",
			      NULL);
    if(l && check_list(l, name, out))
	return KRB5_NT_UNKNOWN;
    l = krb5_config_get_list (context,
			      NULL,
			      "libdefaults",
			      "v4_name_convert",
			      "host",
			      NULL);
    if(l && check_list(l, name, out))
	return KRB5_NT_UNKNOWN;
    
    /* didn't find it in config file, try built-in list */
    {
	struct v4_name_convert *q;
	for(q = default_v4_name_convert; q->from; q++) {
	    if(strcmp(name, q->to) == 0) {
		*out = q->from;
		return KRB5_NT_SRV_HST;
	    }
	}
    }
    return -1;
}
Example #8
0
File: example.c Project: cap/sort_r
int main()
{
  /* sort 1..19, 30..20, 30..100 */
  #define LEN 18
  int arr[LEN] = {1, 5, 28, 4, 3, 2, 10, 20, 18, 25, 21, 29, 34, 35, 14, 100, 27, 19};
  int ans[LEN] = {1, 2, 3, 4, 5, 10, 14, 18, 19, 29, 28, 27, 25, 21, 20, 34, 35, 100};
  int tmp[LEN];

  /* Region to invert: 20-30 (inclusive) */
  int interval[2] = {20, 30};
  int i, res = 1;
  const int tlen = 100000;
  int *tarray = NULL;

  printf("Test 1:\n");
  printf("sort_r\n");
  memcpy(tmp, arr, LEN*sizeof(int));
  print_list(tmp, LEN);
  sort_r(tmp, LEN, sizeof(int), sort_r_cmp, interval);
  print_list(tmp, LEN);
  res &= check_list(tmp, ans, LEN);

  printf("sort_r_simple\n");
  memcpy(tmp, arr, LEN*sizeof(int));
  print_list(tmp, LEN);
  sort_r_simple(tmp, LEN, sizeof(int), sort_r_cmp, interval);
  print_list(tmp, LEN);
  res &= check_list(tmp, ans, LEN);

  printf("Test 2:\n");
  tarray = malloc(tlen * sizeof(int));
  for(i = 0; i < tlen; i++) tarray[i] = i;
  /* sort integers */
  sort_r(tarray, tlen, sizeof(tarray[0]), cmp_int, NULL);
  for(i = 0; i < tlen && tarray[i] == i; i++) {}
  res &= (i == tlen);
  sort_r_simple(tarray, tlen, sizeof(tarray[0]), cmp_int, NULL);
  for(i = 0; i < tlen && tarray[i] == i; i++) {}
  res &= (i == tlen);
  /* reverse sort integers */
  sort_r(tarray, tlen, sizeof(tarray[0]), cmpr_int, NULL);
  for(i = 0; i < tlen && tarray[i] == tlen-i-1; i++) {}
  res &= (i == tlen);
  sort_r_simple(tarray, tlen, sizeof(tarray[0]), cmpr_int, NULL);
  for(i = 0; i < tlen && tarray[i] == tlen-i-1; i++) {}
  res &= (i == tlen);
  free(tarray);

  printf("return: %s\n", res ? "PASS" : "FAIL");
  return res ? EXIT_SUCCESS : EXIT_FAILURE;
}
Example #9
0
static void slab_checker(void) {
	struct _kmem_cache *searchp;
	struct kmem_list3 *l3;
	int i;
	mutex_lock(cache_chain_mutex);
	list_for_each_entry(searchp, cache_chain, next)
	{
		printk("--z-- checking %s\n", searchp->name);
		for (i = 0; i < MAX_NUMNODES; i++) {
			l3 = searchp->nodelists[i];
			check_list(&l3->slabs_partial);
			check_list(&l3->slabs_full);
			check_list(&l3->slabs_free);
		}
	}
Example #10
0
void  brute_force(struct s_list *list, char **square)
{
  int i;
  int j;

  i = 0;
  while (square[i])
  {
    j = 0;
    while (square[i][j])
    {
      if (square[i][j] == '.')
      {
/*
        while (list->flag == 1)
        {
          printf("on continue");
          list = list->next;
          continue ;
      }*/
        if (list->flag == 0 && set_a_jeton(square, &list, i, j) == 0)
        {
          list = list->next;
          display(square); // a enlever
        }
      }
      j++;
    }
    i++;
  }
 if (check_list(list) == -1)
    brute_force(list, square);
}
Example #11
0
void setup(void) {
  array_t *a = array_create(0);

  list_null = datalist_create(NULL);
  check_list(list_null, 0);

  array_push(a, str_wrap("test"));
  array_push(a, data_true());
  array_push(a, data_null());
  array_push(a, int_to_data(42));
  list_array = datalist_create(a);
  check_list(list_array, array_size(a));

  list_valist = (datalist_t *) data_create(List, 2, str_wrap("test"), int_to_data(42));
  check_list(list_valist, 2);
}
Example #12
0
int main(int argc, char *argv[])
{
  int ret;

  ret = check_list();
  if(ret)
    {
      fprintf(stderr, "LIST fails: %d\n", ret);
      return 1;
    }

  ret = check_stack();
  if(ret)
    {
      fprintf(stderr, "STACK fails: %d\n", ret);
      return 2;
    }

  ret = check_queue();
  if(ret)
    {
      fprintf(stderr, "QUEUE fails: %d\n", ret);
      return 3;
    }

  return 0;
}
Example #13
0
t_match		*check_space_pvp(t_match *match, int flag)
{
  int		check;

  check = 0;
  if (check_list(match) == 1)
    {
      flag = 1;
      return (match);
    }
  check = init_check(match);
  if (is_ok(match, check) == 1)
    {
      flag = 1;
      return (match);
    }
  flag = burn_select(&match, flag);
  if (flag != 0)
    {
      is_finished(match);
      if (who_play == 0)
	who_play = 42;
      else
	who_play = 0;
    }
  return (match);
}
Example #14
0
int				my_parse(t_fdf *e, int ac, char **av)
{
	int		i;
	int		fd;
	t_list	*list;

	if ((fd = open(av[1], O_RDWR)) < 0 && ft_printf("fdf: %s: ", av[1]))
	{
		perror("");
		return (0);
	}
	if ((i = my_filllist(&list, fd)) == -2)
		return (0);
	if (close(fd) && ft_printf("fdf: %s: ", av[1]))
	{
		perror("");
		return (0);
	}
	if (!check_list(e, &list))
		return (0);
	if (i == -1 || ac < 3)
		return ((i == -1) ? 0 : 1);
	if ((e->mic.col = read_color(av[2])) < 0)
		return ((e->mic.col = FDF_COL_MIN) + 1);
	if ((ac < 4 || (e->mac.col = read_color(av[3])) < 0))
		return ((e->mac.col = e->mic.col) + 1);
	return (1);
}
Example #15
0
File: sort_3.c Project: mdambrev/42
void				tri_basic(t_content *axx)
{
	TMP_A(4) = LIST_A(3);
	LIST_I(NB_LIST + 4, 0);
	norm(axx);
	while (check_list(axx, 0) != 0)
	{
		TMP_A(3) = LIST_A(0);
		LIST_I(NB_LIST + 3, 1);
		TMP_A(8) = LIST_A(0);
		LIST_I(NB_LIST + 8, 0);
		LIST_I(NB_LIST + 8, 0);
		if (VALUE_IN(0, 0) < VALUE_IN(0, 1))
		{
			op(axx, 5);
		}
		else if (TMP_IN(3, 1) < VALUE_IN(0, 1))
		{
			op(axx, 0);
		}
		else
		{
			push_b(axx, pos_x(axx, TMP_I(4, 0)));
			LIST_I(NB_LIST + 4, 0);
		}
	}
}
Example #16
0
stp_list_t *
stp_list_copy(const stp_list_t *list)
{
  stp_list_t *ret;
  stp_node_copyfunc copyfunc = stp_list_get_copyfunc(list);
  stp_list_item_t *item = list->start;

  check_list(list);

  ret = stp_list_create();
  stp_list_set_copyfunc(ret, stp_list_get_copyfunc(list));
  /* If we use default (shallow) copy, we can't free the elements of it */
  if (stp_list_get_copyfunc(list))
    stp_list_set_freefunc(ret, stp_list_get_freefunc(list));
  stp_list_set_namefunc(ret, stp_list_get_namefunc(list));
  stp_list_set_long_namefunc(ret, stp_list_get_long_namefunc(list));
  stp_list_set_sortfunc(ret, stp_list_get_sortfunc(list));
  while (item)
    {
      void *data = item->data;
      if (copyfunc)
	stp_list_item_create (ret, NULL, (*copyfunc)(data));
      else
	stp_list_item_create(ret, NULL, data);
      item = stp_list_item_next(item);
    }
  return ret;
}
Example #17
0
EC_API ec_list ec_list_concat( ec_list list1, ec_list list2 )
{
	ec_list_node last;

	check_list(list1);
	check_list(list2);
	last = ec_list_tail( list1 );
	check_node(last);

	if (last)
		NEXT(last) = HEAD(list2);
	else
		HEAD(list1) = HEAD(list2);
	check_list(list1);
	return list1;
}
// check_list
static
void
check_list(const BList &toCheck, const BList &expected)
{
	BList base;
	check_list(toCheck, base, expected);
}
Example #19
0
int main() {
    unsigned long long i;

    list = (struct foo**)malloc(N*sizeof(struct foo));
    DYNAMIC_INIT(foo);

    for (i = 0; i < N; i++) {
	unsigned long long j;
	list[i] = TEST_ALLOC(foo);
	for (j = 0; j < i; j++)
	    if (list[j] == list[i]) {
		fprintf(stderr, "allocated the same chunk twice: %p\n", list[i]);
	    }
	
	list[i]->free = 0;
	list[i]->n = i;
	list[i]->moved = 0;
    }

    for (i = 0; i + 10 < N; i+=10) {
	int j;
	/* free 8 out of 10 */
	for (j = 0; j < 8; j++) {
	    free_foo(i+j);
	}
    }

    check_list();

#ifdef TEST_DEFRAGMENT
    fprintf(stderr, "density before defragment: %f\n", TEST_DENSITY(foo));
    TEST_DEFRAGMENT(foo, relocate, NULL);
    fprintf(stderr, "density after defragment:  %f\n", TEST_DENSITY(foo));
#endif

    check_list();

    for (i = 0; i < N; i++) {
	if (list[i]) free_foo(i);
    }

    TEST_DEINIT(foo);
    free(list);

    return 0;
}
Example #20
0
/* ARGSUSED1 */
uint_t
la_objopen(Link_map *lmp, Lmid_t lmid, uintptr_t *cookie)
{
	uint_t		flags;

	if ((bindto_list == NULL) ||
	    (check_list(bindto_list, lmp->l_name)))
		flags = LA_FLG_BINDTO;
	else
		flags = 0;

	if ((bindfrom_list == NULL) ||
	    (check_list(bindfrom_list, lmp->l_name)))
		flags |= LA_FLG_BINDFROM;

	*cookie = (uintptr_t)lmp->l_name;
	return (flags);
}
/*
	void GetAppList(const char *signature, BList *teamIDList) const
	@case 3			teamIDList is not NULL and not empty, signature is not
					NULL and app(s) with this signature is (are) running
	@results		Should append the team IDs of all running apps with the
					supplied signature to teamIDList.
*/
void GetAppListTester::GetAppListTestB3()
{
	const char *signature = "application/x-vnd.obos-app-run-testapp1";
	// create a list with some dummy entries
	BList list;
	list.AddItem((void*)-7);
	list.AddItem((void*)-42);
	// get a list of running applications for reference
	BRoster roster;
	BList list1(list);
	roster.GetAppList(signature, &list1);
	check_list(list1, list);
	// run some apps
	AppRunner runner1(true);
	AppRunner runner2(true);
	AppRunner runner3(true);
	CHK(runner1.Run("AppRunTestApp1") == B_OK);
	CHK(runner2.Run("AppRunTestApp2") == B_OK);
	CHK(runner3.Run("BMessengerTestApp1") == B_OK);
	BList expectedApps;
	expectedApps.AddItem((void*)runner1.Team());
	expectedApps.AddItem((void*)runner2.Team());
	// get a new app list and check it
	BList list2(list);
	roster.GetAppList(signature, &list2);
	check_list(list2, list, expectedApps);
	// quit app 1
	runner1.WaitFor(true);
	expectedApps.RemoveItem((void*)runner1.Team());
	BList list3(list);
	roster.GetAppList(signature, &list3);
	check_list(list3, list, expectedApps);
	// quit app 2
	runner2.WaitFor(true);
	expectedApps.RemoveItem((void*)runner2.Team());
	BList list4(list);
	roster.GetAppList(signature, &list4);
	check_list(list4, list, expectedApps);
	// quit app 3
	runner3.WaitFor(true);
	BList list5(list);
	roster.GetAppList(signature, &list5);
	check_list(list5, list, expectedApps);
}
Example #22
0
int
main(int argc, char **argv)
{
  int i;
  link_head_t list[] = { /* some lists to operate on */
    LINK_HEAD_INIT(0),
    { DEADINT, DEADINT, DEADPTR, DEADPTR, 0 } /* list[1] is a bad list */
  };
  link_elem_t elem[] = { /* some elements to operate on */
    LINK_ELEM_INIT(OBJECT0),
    LINK_ELEM_INIT(OBJECT1),
    LINK_ELEM_INIT(OBJECT2),
    LINK_ELEM_INIT(OBJECT3),
    LINK_ELEM_INIT(OBJECT4),
    LINK_ELEM_INIT(OBJECT5),
  };
  struct itercheck itcheck = { 0, 0 };

  /* First, build the lists */
  for (i = 0; i < 5; i++)
    if (ll_add(&list[0], &elem[i], LINK_LOC_TAIL, 0))
      return -1; /* failed to initialize test */

  /* Baseline checks */
  check_list(&list[0], 5, &elem[0], &elem[4], "ll_iter_baseline",
	     "Verify baseline list");

  /* Check to see if ll_iter() verifies its arguments correctly */
  check_result(ll_iter(0, 0, 0), DB_ERR_BADARGS, "ll_iter_noargs",
	       "ll_iter() with no arguments", 0);
  check_result(ll_iter(&list[1], check_iter, &itcheck), DB_ERR_BADARGS,
	       "ll_iter_badlist", "ll_iter() with bad list", 0);
  check_result(ll_iter(&list[0], 0, &itcheck), DB_ERR_BADARGS,
	       "ll_iter_badfunc", "ll_iter() with bad function", 0);

  /* Now check to see if ll_iter() returns what the iter function returns */
  check_result(ll_iter(&list[0], check_iter, &itcheck), EINVAL,
	       "ll_iter_funcreturn",
	       "ll_iter() returning iteration function return value", 0);

  /* Now iterate through the list */
  itcheck.elem_array = elem;
  itcheck.elem_idx = 0;
  check_result(ll_iter(&list[0], check_iter, &itcheck), 0, "ll_iter_function",
	       "ll_iter() iteration", 0);

  /* Did it check them all? */
  if (itcheck.elem_idx == 5)
    printf("PASS/ll_iter_func_count:ll_iter() visited all items\n");
  else
    printf("FAIL/ll_iter_func_count:ll_iter() visited only %d items\n",
	   itcheck.elem_idx);

  return 0;
}
Example #23
0
uint_t
la_objopen(Link_map *lmp, Lmid_t lmid, uintptr_t *cookie)
{
        uint_t	flags;
        //if (lmid == LM_ID_BASE)
           //     (void) fprintf(output,"file: %s loaded\n", lmp->l_name);
         
	if ((bindto_list == NULL) ||
	    (check_list(bindto_list, lmp->l_name)))
		flags = LA_FLG_BINDTO;
	else
		flags = 0;

	if ((bindfrom_list == NULL) ||
	    (check_list(bindfrom_list, lmp->l_name)))
		flags |= LA_FLG_BINDFROM;
        *cookie = (uintptr_t)lmp->l_name;
	return (flags);
    
  
}
Example #24
0
EC_API EcBool ec_list_finddata( ec_list list, EcAny key, EcAny *data )
{
	ec_list_node node;

	check_list(list);
	node = ec_list_find( list, key );
	if (! node) return FALSE;
	check_node(node);
	if (data)
		*data = DATA(node);
	return TRUE;
}
Example #25
0
//  Return non-NULL if success, NULL if object exists
struct ZSTLMapEntry *ZSTLMapCreate(struct ZSTLMap *pm, char *pkey, uint32_t keylen, char *pdata, uint64_t datalen)
{
    ZSTLMapEntry_t   *pme;
    ZSTLMapBucket_t  *pb;

    do_lock(&(pm->mutex));

    #ifdef SANDISK_PRINTSTUFF
	fprintf(stderr, "ZSTLMapCreate: pm=%p, key=0x%lx, keylen=%d, pdata=%p, datalen=%ld, ", pm, *((uint64_t *) pkey), keylen, pdata, datalen);
    #endif

    pme = find_pme(pm, pkey, keylen, &pb);

    if (pme != NULL) {
	#ifdef SANDISK_PRINTSTUFF
	    fprintf(stderr, "pme=%p\n", pme);
	#endif

	do_unlock(&(pm->mutex));
        return(NULL);
    }

    /* Create a new entry. */

    pme = create_pme(pm, pkey, keylen, pdata, datalen);

    /* put myself on the bucket list */
    pme->bucket = pb;
    pme->next = pb->entry;
    pb->entry = pme;
    #ifdef LISTCHECK
        check_list(pb, pme);
    #endif

    pm->n_entries++;

    /* put myself on the lru list */
    {
        insert_lru(pm, pme);

	if ((pm->max_entries > 0) && (pm->n_entries > pm->max_entries)) {
	    // do an LRU replacement
	    replace_lru(pm, pme);
	}
    }

    do_unlock(&(pm->mutex));
    #ifdef SANDISK_PRINTSTUFF
	fprintf(stderr, "pme=%p\n", pme);
    #endif

    return(pme);
}
Example #26
0
EC_API ec_list_node ec_list_tail( ec_list list )
{
	ec_list_node node;

	check_list(list);
	/* find the last node */
	for (node = HEAD(list); node && NEXT(node); node = NEXT(node))
		check_node(node)
		;

	return node;
}
Example #27
0
EC_API ec_list ec_list_create( void )
{
	ec_list list;

	list = (ec_list) ec_malloc( sizeof(struct ec_list_struct) );
	if (! list) return NULL;

	make_magic_list(list);
	HEAD(list) = NULL;
	check_list(list);
	return list;
}
Example #28
0
EC_API ec_list_node ec_list_prepend( ec_list list, EcAny key, EcAny data )
{
	ec_list_node newnode;

	check_list(list);
	newnode = alloc_node( key, data );
	ASSERT( newnode );
	if (! newnode) return NULL;									/* argh ! */
	NEXT(newnode) = HEAD(list);
	HEAD(list)    = newnode;
	check_node(newnode);
	return newnode;
}
Example #29
0
EC_API ec_list_iterator ec_list_iterator_create( ec_list list )
{
	ec_list_iterator iter;

	check_list(list);
	iter = (ec_list_iterator) ec_malloc( sizeof(struct ec_list_iterator_struct) );
	if (! iter) return NULL;

	make_magic_iter(iter);
	ITLIST(iter) = list;
	ITPOS(iter)  = HEAD(ITLIST(iter));
	check_iter(iter);
	return iter;
}
Example #30
0
/* get the first node with long_name; requires a callack function to
   read data */
stp_list_item_t *
stp_list_get_item_by_long_name(const stp_list_t *list, const char *long_name)
{
  stp_list_item_t *node = NULL;
  stp_list_t *ulist = deconst_list(list);
  check_list(list);

  if (!list->long_namefunc || !long_name)
    return NULL;

  if (list->long_name_cache && list->long_name_cache_node)
    {
      const char *new_long_name;
      node = list->long_name_cache_node;
      /* Is this the item we've cached? */
      if (strcmp(long_name, list->long_name_cache) == 0 &&
	  strcmp(long_name, list->long_namefunc(node->data)) == 0)
	return node;

      /* If not, check the next item in case we're searching the list */
      node = node->next;
      if (node)
	{
	  new_long_name = list->long_namefunc(node->data);
	  if (strcmp(long_name, new_long_name) == 0)
	    {
	      set_long_name_cache(ulist, new_long_name, node);
	      return node;
	    }
	}
      /* If not, check the index cache */
      node = list->index_cache_node;
      if (node)
	{
	  new_long_name = list->long_namefunc(node->data);
	  if (strcmp(long_name, new_long_name) == 0)
	    {
	      set_long_name_cache(ulist, new_long_name, node);
	      return node;
	    }
	}
    }

  node = stp_list_get_item_by_long_name_internal(list, long_name);

  if (node)
    set_long_name_cache(ulist, long_name, node);

  return node;
}