+2021-08-07 Bruno Haible <bruno@clisp.org>
+
+ hash: Improve GCC 11 allocation-deallocation checking.
+ * lib/hash.h (hash_free): Move declaration up.
+ (hash_initialize, hash_xinitialize): Declare that deallocation must
+ happen through 'hash_free'.
+
2021-08-07 Bruno Haible <bruno@clisp.org>
hamt: Improve GCC 11 allocation-deallocation checking.
typedef bool (*Hash_comparator) (const void *entry1, const void *entry2);
typedef void (*Hash_data_freer) (void *entry);
+/* Reclaim all storage associated with a hash table. If a data_freer
+ function has been supplied by the user when the hash table was created,
+ this function applies it to the data of each entry before freeing that
+ entry. */
+extern void hash_free (Hash_table *table);
+
/* Allocate and return a new hash table, or NULL upon failure. The initial
number of buckets is automatically selected so as to _guarantee_ that you
may insert at least CANDIDATE different user entries before any growth of
const Hash_tuning *tuning,
Hash_hasher hasher,
Hash_comparator comparator,
- Hash_data_freer data_freer);
+ Hash_data_freer data_freer)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (hash_free, 1);
/* Same as hash_initialize, but invokes xalloc_die on memory exhaustion. */
/* This function is defined by module 'xhash'. */
const Hash_tuning *tuning,
Hash_hasher hasher,
Hash_comparator comparator,
- Hash_data_freer data_freer);
+ Hash_data_freer data_freer)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (hash_free, 1)
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
/* Make all buckets empty, placing any chained entries on the free list.
Apply the user-specified function data_freer (if any) to the datas of any
affected entries. */
extern void hash_clear (Hash_table *table);
-/* Reclaim all storage associated with a hash table. If a data_freer
- function has been supplied by the user when the hash table was created,
- this function applies it to the data of each entry before freeing that
- entry. */
-extern void hash_free (Hash_table *table);
-
/*
* Insertion and deletion.
*/