void init_caches(uint32_t count) { if (count == 0) count = MAX_LINE_COUNT; assert(count > 0); assert(key_cache == NULL); assert(value_cache == NULL); key_cache = mem_cache_create(sizeof(uint32_t), count); value_cache = mem_cache_create(sizeof(logrecord_t), count); ipseg_cache = mem_cache_create(sizeof(ip_seg), MAX_A_LIST_LINES); assert(wb_list_map == NULL); wb_list_map = hash_table_new(int32_hash, int32_compare_func, NULL, NULL, NULL); assert(a_list == NULL); a_list = list_new(MAX_A_LIST_LINES, NULL); assert(regular_map == NULL); assert(tcp80_map == NULL); assert(tcp443_map == NULL); assert(tcp8080_map == NULL); regular_map = hash_table_new(int32_hash, int32_compare_func, NULL, NULL, NULL); tcp80_map = hash_table_new(int32_hash, int32_compare_func, NULL, NULL, NULL); tcp443_map = hash_table_new(int32_hash, int32_compare_func, NULL, NULL, NULL); tcp8080_map = hash_table_new(int32_hash, int32_compare_func, NULL, NULL, NULL); }
void test_hash_table_new_free(void) { HashTable *hash_table; hash_table = hash_table_new(int_hash, int_equal); assert(hash_table != NULL); /* Add some values */ hash_table_insert(hash_table, &value1, &value1); hash_table_insert(hash_table, &value2, &value2); hash_table_insert(hash_table, &value3, &value3); hash_table_insert(hash_table, &value4, &value4); /* Free the hash table */ hash_table_free(hash_table); /* Test out of memory scenario */ alloc_test_set_limit(0); hash_table = hash_table_new(int_hash, int_equal); assert(hash_table == NULL); assert(alloc_test_get_allocated() == 0); alloc_test_set_limit(1); hash_table = hash_table_new(int_hash, int_equal); assert(hash_table == NULL); assert(alloc_test_get_allocated() == 0); }
int main(int argc, char ** argv) { int i; struct hash_table * table = hash_table_new(1); struct client * cli = malloc(sizeof(struct client)); cli->name = "foo bar"; cli->credit = 5; hash_table_store(table, cli->name, cli); cli = malloc(sizeof(struct client)); cli->name = "far bar"; cli->credit = 6; hash_table_store(table, cli->name, cli); cli = hash_table_delete(table, "foo bar"); /* returns the deleted value */ printf("deleting: %i, should be 1\n", cli != NULL); cli = hash_table_delete(table, "doesn't exist"); /* returns NULL */ printf("deleting: %i, should be 1\n", cli == NULL); struct client * cl2 = hash_table_get(table, "far bar"); printf("%s has %i money\n", cl2->name, cl2->credit); /* get all of the keys and list them */ char ** keys = hash_table_get_all_keys(table); for (i = 0; i < table->population; i++) { printf("key: %s\n", keys[i]); } free(keys); free(cli); free(cl2); hash_table_destroy(table, free_fn); return 0; }
void fsg_model_trans_add(fsg_model_t * fsg, int32 from, int32 to, int32 logp, int32 wid) { fsg_link_t *link; glist_t gl; gnode_t *gn; if (fsg->trans[from].trans == NULL) fsg->trans[from].trans = hash_table_new(5, HASH_CASE_YES); /* Check for duplicate link (i.e., link already exists with label=wid) */ for (gn = gl = fsg_model_trans(fsg, from, to); gn; gn = gnode_next(gn)) { link = (fsg_link_t *) gnode_ptr(gn); if (link->wid == wid) { if (link->logs2prob < logp) link->logs2prob = logp; return; } } /* Create transition object */ link = listelem_malloc(fsg->link_alloc); link->from_state = from; link->to_state = to; link->logs2prob = logp; link->wid = wid; /* Add it to the list of transitions and update the hash table */ gl = glist_add_ptr(gl, (void *) link); hash_table_replace_bkey(fsg->trans[from].trans, (char const *) &link->to_state, sizeof(link->to_state), gl); }
/* Insert -hmmdump, -lm, -svq4svq, -beam, -lminmemory into a hash and display it. */ int main(int argc, char **argv) { hash_table_t *ht; ht = hash_table_new(75, 0); if (hash_table_enter(ht, "-hmmdump", (void *)1) != (void *)1) { E_FATAL("Insertion of -hmmdump failed\n"); } if (hash_table_enter(ht, "-svq4svq", (void *)1) != (void *)1) { E_FATAL("Insertion of -svq4svq failed\n"); } if (hash_table_enter(ht, "-lm", (void *)1) != (void *)1) { E_FATAL("Insertion of -lm failed\n"); } if (hash_table_enter(ht, "-beam", (void *)1) != (void *)1) { E_FATAL("Insertion of -beam failed\n"); } if (hash_table_enter(ht, "-lminmemory", (void *)1) != (void *)1) { E_FATAL("Insertion of -lminmemory failed\n"); } hash_table_display(ht, 1); hash_table_free(ht); ht = NULL; return 0; }
static bool http_request_init(http_request_t *req) { url_t * url = url_parse(req->url); char * uri = url_get_uri(url); req->uri = uri ? strdup(uri) : strdup("/"); if(uri) { free(uri); } http_conn_t * conn = http_conn_new(url->host, url->port ? url->port : 80); assert(conn != NULL); if(!conn) { return false; } req->conn = conn; url_free(url); sstring_init(&req->header, 200); sstring_init(&req->res_header, 512); sstring_init(&req->response, 2048); req->ht_headers = hash_table_new(20, free); req->error = NULL; return true; }
int main(int argc, char **argv) { setvbuf(stdout, NULL, _IOLBF, 0); CmdLine* cmd_line = cmd_line_alloc(); if (cmd_line==NULL) { return -1; } parse_cmdline(cmd_line, argc, argv, sizeof(Element)); dBGraph * db_graph = NULL; //Create the de Bruijn graph/hash table int max_retries=15; db_graph = hash_table_new(cmd_line->mem_height, cmd_line->mem_width, max_retries, cmd_line->kmer_size); if (db_graph==NULL) { return -1; } //some setup int file_reader_fasta(FILE * fp, Sequence * seq, int max_read_length, boolean new_entry, boolean * full_entry){ long long ret; int offset = 0; if (new_entry == false){ offset = db_graph->kmer_size; //die("new_entry must be true in hsi test function"); } ret = read_sequence_from_fasta(fp, seq, max_read_length,new_entry,full_entry,offset); return ret; }
int main(int argc, char *argv[]) { hash_table_t *h; hash_iter_t *itor; /* Test insertion */ TEST_ASSERT(h = hash_table_new(42, FALSE)); TEST_EQUAL((void*)0xdeadbeef, hash_table_enter(h, "foo", (void*)0xdeadbeef)); TEST_EQUAL((void*)0xdeadbeef, hash_table_enter(h, "foo", (void*)0xd0d0feed)); TEST_EQUAL((void*)0xcafec0de, hash_table_enter(h, "bar", (void*)0xcafec0de)); TEST_EQUAL((void*)0xeeefeeef, hash_table_enter(h, "baz", (void*)0xeeefeeef)); TEST_EQUAL((void*)0xbabababa, hash_table_enter(h, "quux", (void*)0xbabababa)); /* Now test iterators. */ for (itor = hash_table_iter(h); itor; itor = hash_table_iter_next(itor)) { printf("%s %p\n", itor->ent->key, itor->ent->val); if (0 == strcmp(itor->ent->key, "foo")) { TEST_EQUAL(itor->ent->val, (void*)0xdeadbeef); } else if (0 == strcmp(itor->ent->key, "bar")) { TEST_EQUAL(itor->ent->val, (void*)0xcafec0de); } else if (0 == strcmp(itor->ent->key, "baz")) { TEST_EQUAL(itor->ent->val, (void*)0xeeefeeef); } else if (0 == strcmp(itor->ent->key, "quux")) { TEST_EQUAL(itor->ent->val, (void*)0xbabababa); } } return 0; }
void test_hash_iterator_key_pair() { HashTable *hash_table; HashTableIterator iterator; HashTablePair pair; int *key = 0; int *val = 0; hash_table = hash_table_new(int_hash, int_equal); /* Add some values */ hash_table_insert(hash_table, &value1, &value1); hash_table_insert(hash_table, &value2, &value2); hash_table_iterate(hash_table, &iterator); while (hash_table_iter_has_more(&iterator)) { /* Retrieve both Key and Value */ pair = hash_table_iter_next(&iterator); key = (int*) pair.key; val = (int*) pair.value; assert(*key == *val); } hash_table_free(hash_table); }
HashTable *generate_hash_table(void) { HashTable *hash_table; char buf[10]; char *value; int i; /* Allocate a new hash table. We use a hash table with keys that are * string versions of the integer values 0..9999 to ensure that there * will be collisions within the hash table (using integer values * with int_hash causes no collisions) */ hash_table = hash_table_new(string_hash, string_equal); /* Insert lots of values */ for (i=0; i<NUM_TEST_VALUES; ++i) { sprintf(buf, "%i", i); value = strdup(buf); hash_table_insert(hash_table, value, value); } /* Automatically free all the values with the hash table */ hash_table_register_free_functions(hash_table, NULL, free); return hash_table; }
huff_code_t * huff_code_read(FILE *infh) { huff_code_t *hc; uint32 i, j; hc = (huff_code_t*)ckd_calloc(1, sizeof(*hc)); hc->refcount = 1; hc->maxbits = fgetc(infh); hc->type = fgetc(infh); /* Two bytes of padding. */ fgetc(infh); fgetc(infh); /* Allocate stuff. */ hc->firstcode = (uint32*)ckd_calloc(hc->maxbits + 1, sizeof(*hc->firstcode)); hc->numl = (uint32*)ckd_calloc(hc->maxbits + 1, sizeof(*hc->numl)); hc->syms = (huff_codeword_t**)ckd_calloc(hc->maxbits + 1, sizeof(*hc->syms)); /* Read the symbol tables. */ hc->codewords = hash_table_new(hc->maxbits, HASH_CASE_YES); for (i = 1; i <= hc->maxbits; ++i) { if (fread(&hc->firstcode[i], 4, 1, infh) != 1) goto error_out; SWAP_BE_32(&hc->firstcode[i]); if (fread(&hc->numl[i], 4, 1, infh) != 1) goto error_out; SWAP_BE_32(&hc->numl[i]); hc->syms[i] =(huff_codeword_t*) ckd_calloc(hc->numl[i], sizeof(**hc->syms)); for (j = 0; j < hc->numl[i]; ++j) { huff_codeword_t *cw = &hc->syms[i][j]; cw->nbits = i; cw->codeword = hc->firstcode[i] + j; if (hc->type == HUFF_CODE_INT) { if (fread(&cw->r.ival, 4, 1, infh) != 1) goto error_out; SWAP_BE_32(&cw->r.ival); hash_table_enter_bkey(hc->codewords, (char const *)&cw->r.ival, sizeof(cw->r.ival), (void *)cw); } else { size_t len; cw->r.sval = fread_line(infh, &len); cw->r.sval[len-1] = '\0'; hash_table_enter(hc->codewords, cw->r.sval, (void *)cw); } } } return hc; error_out: huff_code_free(hc); return 0; }
jsgf_t * jsgf_grammar_new(jsgf_t *parent) { jsgf_t *grammar; grammar = ckd_calloc(1, sizeof(*grammar)); /* If this is an imported/subgrammar, then we will share a global * namespace with the parent grammar. */ if (parent) { grammar->rules = parent->rules; grammar->imports = parent->imports; grammar->searchpath = parent->searchpath; grammar->parent = parent; } else { char *jsgf_path; grammar->rules = hash_table_new(64, 0); grammar->imports = hash_table_new(16, 0); /* Silvio Moioli: no getenv() in Windows CE */ #if !defined(_WIN32_WCE) if ((jsgf_path = getenv("JSGF_PATH")) != NULL) { char *word, *c; /* FIXME: This should be a function in libsphinxbase. */ /* FIXME: Also nextword() is totally useless... */ word = jsgf_path = ckd_salloc(jsgf_path); while ((c = strchr(word, ':'))) { *c = '\0'; grammar->searchpath = glist_add_ptr(grammar->searchpath, word); word = c + 1; } grammar->searchpath = glist_add_ptr(grammar->searchpath, word); grammar->searchpath = glist_reverse(grammar->searchpath); } else { /* Default to current directory. */ grammar->searchpath = glist_add_ptr(grammar->searchpath, ckd_salloc(".")); } #endif } return grammar; }
void dict_init(void) { #ifdef AVLTREE root = NULL; #else root = hash_table_new(); #endif }
static void build_widmap(ngram_model_t * base, logmath_t * lmath, int32 n) { ngram_model_set_t *set = (ngram_model_set_t *) base; ngram_model_t **models = set->lms; hash_table_t *vocab; glist_t hlist; gnode_t *gn; int32 i; /* Construct a merged vocabulary and a set of word-ID mappings. */ vocab = hash_table_new(models[0]->n_words, FALSE); /* Create the set of merged words. */ for (i = 0; i < set->n_models; ++i) { int32 j; for (j = 0; j < models[i]->n_words; ++j) { /* Ignore collisions. */ (void) hash_table_enter_int32(vocab, models[i]->word_str[j], j); } } /* Create the array of words, then sort it. */ if (hash_table_lookup(vocab, "<UNK>", NULL) != 0) (void) hash_table_enter_int32(vocab, "<UNK>", 0); /* Now we know the number of unigrams, initialize the base model. */ ngram_model_init(base, &ngram_model_set_funcs, lmath, n, hash_table_inuse(vocab)); base->writable = FALSE; /* We will reuse the pointers from the submodels. */ i = 0; hlist = hash_table_tolist(vocab, NULL); for (gn = hlist; gn; gn = gnode_next(gn)) { hash_entry_t *ent = gnode_ptr(gn); base->word_str[i++] = (char *) ent->key; } glist_free(hlist); qsort(base->word_str, base->n_words, sizeof(*base->word_str), my_compare); /* Now create the word ID mappings. */ if (set->widmap) ckd_free_2d((void **) set->widmap); set->widmap = (int32 **) ckd_calloc_2d(base->n_words, set->n_models, sizeof(**set->widmap)); for (i = 0; i < base->n_words; ++i) { int32 j; /* Also create the master wid mapping. */ (void) hash_table_enter_int32(base->wid, base->word_str[i], i); /* printf("%s: %d => ", base->word_str[i], i); */ for (j = 0; j < set->n_models; ++j) { set->widmap[i][j] = ngram_wid(models[j], base->word_str[i]); /* printf("%d ", set->widmap[i][j]); */ } /* printf("\n"); */ } hash_table_free(vocab); }
num_space_collapser_t *num_space_collapser_new (void) { num_space_collapser_t *nsc = (num_space_collapser_t *)calloc(sizeof(num_space_collapser_t), 1); pthread_mutex_init(&nsc->mutex, NULL); nsc->hash_table = hash_table_new(32); return nsc; }
jsgf_t * jsgf_grammar_new(jsgf_t * parent) { jsgf_t *grammar; grammar = ckd_calloc(1, sizeof(*grammar)); /* If this is an imported/subgrammar, then we will share a global * namespace with the parent grammar. */ if (parent) { grammar->rules = parent->rules; grammar->imports = parent->imports; grammar->searchpath = parent->searchpath; grammar->parent = parent; } else { grammar->rules = hash_table_new(64, 0); grammar->imports = hash_table_new(16, 0); } return grammar; }
void test_hash_table_free_functions(void) { HashTable *hash_table; int *key; int *value; int i; /* Create a hash table, fill it with values */ hash_table = hash_table_new(int_hash, int_equal); hash_table_register_free_functions(hash_table, free_key, free_value); allocated_values = 0; for (i=0; i<NUM_TEST_VALUES; ++i) { key = new_key(i); value = new_value(99); hash_table_insert(hash_table, key, value); } assert(allocated_keys == NUM_TEST_VALUES); assert(allocated_values == NUM_TEST_VALUES); /* Check that removing a key works */ i = NUM_TEST_VALUES / 2; hash_table_remove(hash_table, &i); assert(allocated_keys == NUM_TEST_VALUES - 1); assert(allocated_values == NUM_TEST_VALUES - 1); /* Check that replacing an existing key works */ key = new_key(NUM_TEST_VALUES / 3); value = new_value(999); assert(allocated_keys == NUM_TEST_VALUES); assert(allocated_values == NUM_TEST_VALUES); hash_table_insert(hash_table, key, value); assert(allocated_keys == NUM_TEST_VALUES - 1); assert(allocated_values == NUM_TEST_VALUES - 1); /* A free of the hash table should free all of the keys and values */ hash_table_free(hash_table); assert(allocated_keys == 0); assert(allocated_values == 0); }
int main(int argc, char *argv[]) { HashTable *htable; Value *value; unsigned int key; int i; printf("creating hash table\n"); htable = hash_table_new(NULL, key_compare_func, destroy_key_func, destroy_value_func); if ( NULL == htable) { fprintf(stderr, "hash_table_new failed \n"); return -1; } for (i = 0; i<20; i++) { key = i; value = (Value *)malloc(sizeof(Value)); if (NULL == value) { printf("Failed to allocate data\n"); return -1; } value->data = i; sprintf(value->str, "entry %d was added", i); printf("adding entry %d\n",i); hash_table_insert(htable, &key, value); } for (i=0 ; i<20; i++) { value = hash_table_lookup(htable, &i); if (NULL != value) { printf("value->data = %d\n", value->data); printf("value->str = %s\n", value->str); } } printf("destroying hash table\n"); hash_table_destroy(htable); return 0; }
static struct hash_table * id_table_create() { struct hash_table *table; table = hash_table_new(INITIAL_SZ, (hash_callback_t)id_hash_cb, (hash_compare_t)id_compare); if (table == NULL) print_warn_and_die("error at table table creation\n"); return table; }
struct hash_table * id_table_create() { struct hash_table *table; table = hash_table_new(INITIAL_SZ, (hash_callback_t)default_hash_cb, (hash_compare_t)default_hash_compare); if (table == NULL) error(1, "error at table table creation\n"); return table; }
int ngram_model_casefold(ngram_model_t * model, int kase) { int writable, i; hash_table_t *new_wid; /* Were word strings already allocated? */ writable = model->writable; /* Either way, we are going to allocate some word strings. */ model->writable = TRUE; /* And, don't forget, we need to rebuild the word to unigram ID * mapping. */ new_wid = hash_table_new(model->n_words, FALSE); for (i = 0; i < model->n_words; ++i) { char *outstr; if (writable) { outstr = model->word_str[i]; } else { outstr = ckd_salloc(model->word_str[i]); } /* Don't case-fold <tags> or [classes] */ if (outstr[0] == '<' || outstr[0] == '[') { } else { switch (kase) { case NGRAM_UPPER: ucase(outstr); break; case NGRAM_LOWER: lcase(outstr); break; default: ; } } model->word_str[i] = outstr; /* Now update the hash table. We might have terrible * collisions here, so warn about them. */ if (hash_table_enter_int32(new_wid, model->word_str[i], i) != i) { E_WARN("Duplicate word in dictionary after conversion: %s\n", model->word_str[i]); } } /* Swap out the hash table. */ hash_table_free(model->wid); model->wid = new_wid; return 0; }
int main() { struct hash_table_t *ht = hash_table_new(sizeof(int32_t), sizeof(int32_t), 10); int i; uint32_t key, value, *rvalue; for(i=0;i<20;++i) { key = i; value = i; hash_table_insert(ht, &key, &value); rvalue = (uint32_t *)hash_table_lookup(ht, &key); assert(value == *rvalue); } return 0; }
static void dp_init(void) { node_alloc = (node_t *) ckd_calloc(((MAX_HYP_LEN << 1) + 1) * MAX_HYP_LEN, sizeof(node_t)); dict_ht = hash_table_new(DP_HASH_SIZE, HASH_CASE_YES); n_word_alloc = DP_HASH_SIZE; word = (char **) ckd_calloc(n_word_alloc, sizeof(char *)); n_word = 0; silwid = word2id(" "); }
void la_initialize(la_UUID_t seed) { assert(la_buffer_table == LA_NULL); la_buffer_table = hash_table_new( &__la_hash_buffer_table_key, &__la_compare_buffer_table_keys); assert(la_buffer_table != LA_NULL); hash_table_register_free_functions( la_buffer_table, &__la_free_buffer_table_key, &__la_free_buffer_table_value); LOGD("%lu (successfully created buffer table)", seed); }
FinCStruct* finc_struct_new(String* p_name) { FinCStruct *self; self = (FinCStruct*)mem_new (sizeof(FinCStruct)); object_init_object (OBJECT (self), finc_struct_destroy); self->name = addref (String, p_name); self->hash_field = hash_table_new (string_hash, string_equal); self->size = 0; self->next_index = 0; return self; }
/** * @param set * @param first_bytes * @param last_bytes * @param num_bytes */ product_distribution_t * product_distribution_new(LST_StringSet * set, int first_bytes, int last_bytes, int num_bytes){ if(!set) { return NULL; } product_distribution_t * pd = (product_distribution_t *) malloc (sizeof(product_distribution_t)); pd->first_bytes = first_bytes; pd->last_bytes = last_bytes; pd->num_bytes = num_bytes; pd->offset_distribution = hash_table_new(int_hash, int_equal); lst_stringset_foreach(set, calculate_product_distribution_callback, pd); return pd; }
void hash_ctx_table_init() { if (ctx_table != NULL) error(1, "ctx table already initialisated!\n"); ctx_table = xmalloc(sizeof(*ctx_table)); ctx_table->hash = hash_table_new(INITIAL_SZ, (hash_callback_t )default_hash_cb, (hash_compare_t )default_hash_compare); ctx_table->count = 0; if (ctx_table->hash == NULL) error(1, "error at table table creation\n"); }
static void sseq_compress(mdef_t * m) { hash_table_t *h; s3senid_t **sseq; int32 n_sseq; int32 p, j, k; glist_t g; gnode_t *gn; hash_entry_t *he; k = m->n_emit_state * sizeof(s3senid_t); h = hash_table_new(m->n_phone, HASH_CASE_YES); n_sseq = 0; /* Identify unique senone-sequence IDs. BUG: tmat-id not being considered!! */ for (p = 0; p < m->n_phone; p++) { /* Add senone sequence to hash table */ if ((j = (long) hash_table_enter_bkey(h, (char *) (m->sseq[p]), k, (void *)(long)n_sseq)) == n_sseq) n_sseq++; m->phone[p].ssid = j; } /* Generate compacted sseq table */ sseq = (s3senid_t **) ckd_calloc_2d(n_sseq, m->n_emit_state, sizeof(s3senid_t)); /* freed in mdef_free() */ g = hash_table_tolist(h, &j); assert(j == n_sseq); for (gn = g; gn; gn = gnode_next(gn)) { he = (hash_entry_t *) gnode_ptr(gn); j = (int32)(long)hash_entry_val(he); memcpy(sseq[j], hash_entry_key(he), k); } glist_free(g); /* Free the old, temporary senone sequence table, replace with compacted one */ ckd_free_2d((void **) m->sseq); m->sseq = sseq; m->n_sseq = n_sseq; hash_table_free(h); }
int32 ngram_model_init(ngram_model_t *base, ngram_funcs_t *funcs, logmath_t *lmath, int32 n, int32 n_unigram) { base->refcount = 1; base->funcs = funcs; base->n = n; /* If this was previously initialized... */ if (base->n_counts == NULL) base->n_counts = ckd_calloc(3, sizeof(*base->n_counts)); /* Don't reset weights if logmath object hasn't changed. */ if (base->lmath != lmath) { /* Set default values for weights. */ base->lw = 1.0; base->log_wip = 0; /* i.e. 1.0 */ base->log_uw = 0; /* i.e. 1.0 */ base->log_uniform = logmath_log(lmath, 1.0 / n_unigram); base->log_uniform_weight = logmath_get_zero(lmath); base->log_zero = logmath_get_zero(lmath); base->lmath = lmath; } /* Allocate or reallocate space for word strings. */ if (base->word_str) { /* Free all previous word strings if they were allocated. */ if (base->writable) { int32 i; for (i = 0; i < base->n_words; ++i) { ckd_free(base->word_str[i]); base->word_str[i] = NULL; } } base->word_str = ckd_realloc(base->word_str, n_unigram * sizeof(char *)); } else base->word_str = ckd_calloc(n_unigram, sizeof(char *)); /* NOTE: They are no longer case-insensitive since we are allowing * other encodings for word strings. Beware. */ if (base->wid) hash_table_empty(base->wid); else base->wid = hash_table_new(n_unigram, FALSE); base->n_counts[0] = base->n_1g_alloc = base->n_words = n_unigram; return 0; }
void _cwt_colorx_init(void) { CwtStrNS *strNS = cwt_str_ns(); size_t i; size_t n; __cwt_color_table = hash_table_new(string_hash, string_equal); hash_table_register_free_functions(__cwt_color_table, cwt_free, NULL); n = sizeof(__cwt_color_names)/sizeof(__cwt_color_names[0]); for( i = 0; i < n; i++ ) { CWT_CHAR *key = strNS->strDup(__cwt_color_names[i].name); strNS->toLowerStr(key, key, strNS->strLen(key)); CWT_ASSERT(hash_table_insert(__cwt_color_table , key, &__cwt_color_names[i].color)); } }