bool hash_add(hash_table *table, tc_pool_t *pool, uint64_t key, void *data) { hash_node *hn, *tmp; link_list *l; p_link_node ln; ln = hash_find_node(table, key); if (ln == NULL) { tmp = hash_node_malloc(pool, key, data); if (tmp != NULL) { l = get_link_list(table, key); ln = link_node_malloc(pool, tmp); if (ln != NULL) { link_list_push(l, ln); table->total++; return true; } else { return false; } } else { return false; } } else { hn = (hash_node *) ln->data; hn->data = data; return false; } }
void hash_add(hash_table *table,uint64_t key,void *data){ hash_node *hnode = NULL; hash_node *newnode =NULL; lnodeptr pnode = NULL; linklist *l = NULL; lnodeptr node = hash_find_node(table,key); if(node != NULL){ hnode = (hash_node *) node->data; hnode->data = data; }else { newnode = hash_node_malloc(key,data); pnode = lnode_malloc(newnode); l = get_linklist(table,key); linklist_push(l,pnode); } }