Logo Search packages:      
Sourcecode: likewise-open version File versions  Download package

void CTStableHashTableFree ( PSHASH_TABLE  tab  ) 

Deallocate a table.

Deallocates a table and all associated memory; this includes all keys and values present in the table if the table was created with non-null key_free and value_free parameters. If the table was allocated with CTStableHashTableNew, the SHASH_TABLE structure itself will also be freed.

Parameters:
tab the table to deallocate

Definition at line 192 of file cthash.c.

References SHASH_PAIR::key, SHASH_TABLE::list, SHASH_TABLE::table, and SHASH_PAIR::value.

{
    LWGList* iter;
    
    for (iter = tab->list; iter != NULL; iter = iter->next)
    {
        PSHASH_PAIR pair = (PSHASH_PAIR) iter->data;
        if (pair) {
           if (tab->key_free)
              tab->key_free(pair->key);
           if (tab->value_free)
              tab->value_free(pair->value);
           CTFreeMemory(pair);
        }
    }
    
    lwg_list_free(tab->list);
    tab->list = NULL;

    lwg_hash_table_destroy(tab->table);
    tab->table = NULL;

    if (tab->dynamic)
        CTFreeMemory(tab);

}


Generated by  Doxygen 1.6.0   Back to index