summaryrefslogtreecommitdiffstats
path: root/dhash
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2010-09-29 10:05:30 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-10-12 14:26:07 -0400
commit841a1ab44968f13f0f7b6a2ace4e38d418142cbd (patch)
tree4ac61194fc30af7d82b06085c92cb5dca421be56 /dhash
parent64d27d3e9ec77874895f4dceac4fed89ff95fa12 (diff)
downloadding-libs-841a1ab44968f13f0f7b6a2ace4e38d418142cbd.tar.gz
ding-libs-841a1ab44968f13f0f7b6a2ace4e38d418142cbd.tar.xz
ding-libs-841a1ab44968f13f0f7b6a2ace4e38d418142cbd.zip
dhash: Fix memory leak in example
Diffstat (limited to 'dhash')
-rw-r--r--dhash/examples/dhash_example.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/dhash/examples/dhash_example.c b/dhash/examples/dhash_example.c
index bd0ca8e..c7eac3d 100644
--- a/dhash/examples/dhash_example.c
+++ b/dhash/examples/dhash_example.c
@@ -81,6 +81,7 @@ int main(int argc, char **argv)
fprintf(stderr, "cannot add to table \"%s\" (%s)\n", key.str, hash_error_string(error));
return error;
}
+ free(key.str);
/* Get a list of keys and print them out, free the list when we're done */
if ((error = hash_keys(table, &count, &keys)) != HASH_SUCCESS) {
@@ -98,6 +99,7 @@ int main(int argc, char **argv)
if ((error = hash_lookup(table, &key, &value)) != HASH_SUCCESS) {
fprintf(stderr, "cannot find key \"%s\" (%s)\n", key.str, hash_error_string(error));
}
+ free(key.str);
/* Visit each entry in the table, callback will increment count on each visit */
printf("Iterate using callback\n");
@@ -130,6 +132,7 @@ int main(int argc, char **argv)
/* Assure key is no longer in table */
assert (!hash_has_key(table, &key));
+ free(key.str);
/* Free the table */
hash_destroy(table);