From: Bruno Haible Date: Sat, 7 Aug 2021 17:42:08 +0000 (+0200) Subject: hamt: Improve GCC 11 allocation-deallocation checking. X-Git-Tag: v1.0~2700 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5adafd694ccdddbc6ac476b126d7e7bf0ac7befa;p=gnulib.git 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'. --- diff --git a/ChangeLog b/ChangeLog index 2eb280adf5..d9427ede1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2021-08-07 Bruno Haible + + 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 get_progname_of: Improve GCC 11 allocation-deallocation checking. diff --git a/lib/hamt.h b/lib/hamt.h index 6bbc6a3f42..5d553fc7d1 100644 --- a/lib/hamt.h +++ b/lib/hamt.h @@ -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 */