diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-12-08 14:05:22 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-08 23:35:30 -0500 |
commit | 4a5e256201c886d09a8dadd3f299baadde506a2f (patch) | |
tree | e78333c8b8fac1e468244337819cb863e7babc62 /dhash/dhash_example.c | |
parent | 34d3eb975ec23c9875d54226a5b625a2f9b4ad51 (diff) | |
download | ding-libs-4a5e256201c886d09a8dadd3f299baadde506a2f.tar.gz ding-libs-4a5e256201c886d09a8dadd3f299baadde506a2f.tar.xz ding-libs-4a5e256201c886d09a8dadd3f299baadde506a2f.zip |
dhash: Add private pointer for delete callback
Also pass a flag to the delete callback to tell it if this is a normal
entry removal or we are cleaning up the tbale definitively.
Diffstat (limited to 'dhash/dhash_example.c')
-rw-r--r-- | dhash/dhash_example.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/dhash/dhash_example.c b/dhash/dhash_example.c index b7de623..7ed01d7 100644 --- a/dhash/dhash_example.c +++ b/dhash/dhash_example.c @@ -9,7 +9,7 @@ struct my_data_t { char bar[128]; }; -void delete_callback(hash_entry_t *entry) +void delete_callback(hash_entry_t *entry, hash_destroy_enum type, void *pvt) { if (entry->value.type == HASH_VALUE_PTR) free(entry->value.ptr); } @@ -45,7 +45,8 @@ int main(int argc, char **argv) unsigned long count; /* Create a hash table */ - if ((error = hash_create(10, &table, delete_callback)) != HASH_SUCCESS) { + error = hash_create(10, &table, delete_callback, NULL); + if (error != HASH_SUCCESS) { fprintf(stderr, "cannot create hash table (%s)\n", hash_error_string(error)); return error; } |