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); }
/** 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); }
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; }
/** 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); } }