Ejemplo n.º 1
0
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;
    }
}
Ejemplo n.º 2
0
void * hash_find(hash_table *table,uint64_t key){
	hash_node *hnode=NULL;
	lnodeptr node = hash_find_node(table,key);
	if(node != NULL){
		hnode = (hash_node *) node->data;
		return hnode->data;
	}
	return NULL;
}
Ejemplo n.º 3
0
Archivo: hash.c Proyecto: jbli/tcpcopy
void *hash_find(hash_table *table, uint64_t key)
{
    hash_node   *hn;
    p_link_node ln = hash_find_node(table, key);
    if(ln != NULL){
        hn = (hash_node *) ln->data;
        return hn->data;
    }
    return NULL;
}
Ejemplo n.º 4
0
void hash_del(hash_table *table,uint64_t key){
	lnodeptr node = hash_find_node(table,key);
	if(node != NULL){
		linklist_remove(node);
		if(node->data!=NULL)
		{
			free(node->data);
		}
		node->data=NULL;
		lnode_free(node);
	}
	return;
}
Ejemplo n.º 5
0
Archivo: hash.c Proyecto: jbli/tcpcopy
bool hash_del(hash_table *table, uint64_t key)
{
    link_list   *l = get_link_list(table, key); 
    p_link_node ln = hash_find_node(table, key);
    if(ln != NULL){
        table->total--;
        link_list_remove(l, ln);
        link_node_internal_free(ln);
        free(ln);
        return true;
    }else{
        return false;
    }
}
Ejemplo n.º 6
0
bool
hash_del(hash_table *table, tc_pool_t *pool, uint64_t key)
{
    link_list  *l  = get_link_list(table, key);
    p_link_node ln = hash_find_node(table, key);

    if (ln != NULL) {
        table->total--;
        link_list_remove(l, ln);
        tc_pfree(pool, ln->data);
        tc_pfree(pool, ln);
        return true;
    } else {

        return false;
    }
}
Ejemplo n.º 7
0
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);
	}
}