]> Savannah Git Hosting - gnulib.git/commitdiff
hamt: Improve GCC 11 allocation-deallocation checking.
authorBruno Haible <bruno@clisp.org>
Sat, 7 Aug 2021 17:42:08 +0000 (19:42 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 7 Aug 2021 17:42:08 +0000 (19:42 +0200)
* lib/hamt.h (hamt_free): Move declaration up.
(hamt_create, hamt_copy): Declare that deallocation must happen through
'hamt_free'.

ChangeLog
lib/hamt.h

index 2eb280adf5214432ef00d958df407a789a048fe5..d9427ede1ad5e237acd223b1268348035e465afa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-08-07  Bruno Haible  <bruno@clisp.org>
+
+       hamt: Improve GCC 11 allocation-deallocation checking.
+       * lib/hamt.h (hamt_free): Move declaration up.
+       (hamt_create, hamt_copy): Declare that deallocation must happen through
+       'hamt_free'.
+
 2021-08-07  Bruno Haible  <bruno@clisp.org>
 
        get_progname_of: Improve GCC 11 allocation-deallocation checking.
index 6bbc6a3f4239c3238ac01b5f7de18ec6a1b32aff..5d553fc7d18ebc390839af12bd0986a6413cd2ce 100644 (file)
@@ -138,20 +138,22 @@ typedef void (Hamt_freer) (Hamt_entry *elt);
 /* Creation and Destruction */
 /****************************/
 
+/* Free the resources solely allocated by HAMT and all elements solely
+   contained in it.  */
+extern void hamt_free (Hamt *hamt);
+
 /* Create and return a new and empty hash array mapped trie.  */
 _GL_ATTRIBUTE_NODISCARD
 extern Hamt *hamt_create (Hamt_hasher *hasher, Hamt_comparator *comparator,
-                          Hamt_freer *freer);
+                          Hamt_freer *freer)
+  _GL_ATTRIBUTE_DEALLOC (hamt_free, 1);
 
 /* Return a copy of HAMT, which is not the same in the sense above.
    This procedure can be used, for example, so that two threads can
    access the same data independently.  */
 _GL_ATTRIBUTE_NODISCARD
-extern Hamt *hamt_copy (Hamt *hamt);
-
-/* Free the resources solely allocated by HAMT and all elements solely
-   contained in it.  */
-extern void hamt_free (Hamt *hamt);
+extern Hamt *hamt_copy (Hamt *hamt)
+  _GL_ATTRIBUTE_DEALLOC (hamt_free, 1);
 
 /**********/
 /* Lookup */