예제 #1
0
파일: init.c 프로젝트: andybug/ptab
END_TEST

START_TEST (init_null_allocator)
{
	ptab_allocator_t pa;

	pa.alloc_func = NULL;
	pa.free_func = free_func;
	pa.opaque = (void*)(0xdeadbeef);

	p = ptab_init(&pa);
	ck_assert(p == NULL);

	pa.alloc_func = alloc_func;
	pa.free_func = NULL;

	p = ptab_init(&pa);
	ck_assert(p == NULL);
}
예제 #2
0
/** Build the basic attribute table.
 */
void
init_aname_table(void)
{
  ATTR *ap;

  ptab_init(&ptab_attrib);
  ptab_start_inserts(&ptab_attrib);
  for (ap = attr; ap->name; ap++)
    ptab_insert(&ptab_attrib, ap->name, ap);
  ptab_end_inserts(&ptab_attrib);
}
예제 #3
0
ptab * ptab_add(ptab *pt, char *prefix, void *data)
{
    ptab **p = &pt;
    for (size_t i = 0; i < strlen(prefix); i++) {
        p = &((*p)->prefix[prefix[i] - 'a']);
        if (*p == NULL) {
            *p = ptab_init();
        }
    }

    (*p)->data = data;

    return *p;
}
예제 #4
0
/** Build the basic attribute table.
 */
void
init_aname_table(void)
{
  ATTR *ap;
  ATRALIAS *aap;

  ptab_init(&ptab_attrib);
  ptab_start_inserts(&ptab_attrib);
  for (ap = attr; ap->name; ap++)
    ptab_insert(&ptab_attrib, ap->name, ap);
  ptab_end_inserts(&ptab_attrib);

  for (aap = attralias; aap->alias; aap++) {
    alias_attribute(aap->realname, aap->alias);
  }
}