diff options
author | Eric Anholt <eric@anholt.net> | 2011-08-18 09:27:30 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2011-08-18 09:27:30 -0700 |
commit | 99ad0f60d58f88dc3e12fdce59c76897f220c59b (patch) | |
tree | 6f9e21845efa21612b233b111256ea3d4ec2a01d /tests | |
parent | 391a6c0aefab18eacb83456b3bcb161cc7371773 (diff) |
Make hash_table_remove(ht, NULL) do nothing instead of segfault.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/remove_null.c | 46 |
3 files changed, 48 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore index 41ca9e7..37d555f 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -5,4 +5,5 @@ insert_and_lookup insert_many null_destroy random_entry +remove_null replacement diff --git a/tests/Makefile.am b/tests/Makefile.am index e681df1..df9bccc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -29,6 +29,7 @@ TESTS = \ insert_many \ null_destroy \ random_entry \ + remove_null \ replacement \ $() diff --git a/tests/remove_null.c b/tests/remove_null.c new file mode 100644 index 0000000..1be8f84 --- /dev/null +++ b/tests/remove_null.c @@ -0,0 +1,46 @@ +/* + * Copyright © 2011 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Eric Anholt <eric@anholt.net> + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> +#include "hash_table.h" +#include "fnv_hash.h" + +int +main(int argc, char **argv) +{ + struct hash_table *ht; + + ht = hash_table_create(string_key_equals); + + hash_table_remove(ht, NULL); + + hash_table_destroy(ht, NULL); + + return 0; +} |