diff options
author | Sumit Bose <sbose@redhat.com> | 2010-09-29 10:05:30 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-10-12 14:26:07 -0400 |
commit | 841a1ab44968f13f0f7b6a2ace4e38d418142cbd (patch) | |
tree | 4ac61194fc30af7d82b06085c92cb5dca421be56 /dhash | |
parent | 64d27d3e9ec77874895f4dceac4fed89ff95fa12 (diff) | |
download | ding-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.c | 3 |
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); |