X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fhashmap.c;h=73937ac217358ee42e01edbeb27d43456dd5688d;hb=f9713158cbee03f37bc288a41ea6ca83c4968021;hp=f2a8a77eae0a8d5b905bdc59343c885be6eb94a9;hpb=fc86aa0ed204922dcafa85353cb10e1aa7d91a76;p=elogind.git diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c index f2a8a77ea..73937ac21 100644 --- a/src/shared/hashmap.c +++ b/src/shared/hashmap.c @@ -20,9 +20,7 @@ along with systemd; If not, see . ***/ -#include #include -#include #include #include "util.h" @@ -31,9 +29,12 @@ #include "macro.h" #include "siphash24.h" #include "strv.h" -#include "list.h" #include "mempool.h" +#ifdef ENABLE_DEBUG_HASHMAP +#include "list.h" +#endif + /* * Implementation of hashmaps. * Addressing: open @@ -864,38 +865,41 @@ static void hashmap_free_no_clear(HashmapBase *h) { free(h); } -void internal_hashmap_free(HashmapBase *h) { +HashmapBase *internal_hashmap_free(HashmapBase *h) { /* Free the hashmap, but nothing in it */ - if (!h) - return; + if (h) { + internal_hashmap_clear(h); + hashmap_free_no_clear(h); + } - internal_hashmap_clear(h); - hashmap_free_no_clear(h); + return NULL; } -void internal_hashmap_free_free(HashmapBase *h) { +HashmapBase *internal_hashmap_free_free(HashmapBase *h) { /* Free the hashmap and all data objects in it, but not the * keys */ - if (!h) - return; + if (h) { + internal_hashmap_clear_free(h); + hashmap_free_no_clear(h); + } - internal_hashmap_clear_free(h); - hashmap_free_no_clear(h); + return NULL; } -void hashmap_free_free_free(Hashmap *h) { +Hashmap *hashmap_free_free_free(Hashmap *h) { /* Free the hashmap and all data and key objects in it */ - if (!h) - return; + if (h) { + hashmap_clear_free_free(h); + hashmap_free_no_clear(HASHMAP_BASE(h)); + } - hashmap_clear_free_free(h); - hashmap_free_no_clear(HASHMAP_BASE(h)); + return NULL; } void internal_hashmap_clear(HashmapBase *h) { @@ -1066,7 +1070,7 @@ static int hashmap_base_put_boldly(HashmapBase *h, unsigned idx, /* * Returns 0 if resize is not needed. - * 1 if succesfully resized. + * 1 if successfully resized. * -ENOMEM on allocation failure. */ static int resize_buckets(HashmapBase *h, unsigned entries_add) {