+2021-08-07 Bruno Haible <bruno@clisp.org>
+
+ list, set, oset, map, omap: Prepare allocation-deallocation checking.
+ * lib/gl_list.h (gl_list_create_empty, gl_list_nx_create_empty,
+ gl_list_create, gl_list_nx_create): Add comment that deallocation must
+ happen through 'gl_list_free'.
+ * lib/gl_xlist.h (gl_list_create_empty, gl_list_create): Likewise.
+ * lib/gl_sublist.h (gl_sublist_create, gl_sublist_nx_create): Likewise.
+ * lib/gl_xsublist.h (gl_sublist_create): Likewise.
+ * lib/gl_set.h (gl_set_create_empty, gl_set_nx_create_empty): Add
+ comment that deallocation must happen through 'gl_set_free'.
+ * lib/gl_xset.h (gl_set_create_empty): Likewise.
+ * lib/gl_oset.h (gl_oset_create_empty, gl_oset_nx_create_empty): Add
+ comment that deallocation must happen through 'gl_oset_free'.
+ * lib/gl_xoset.h (gl_oset_create_empty): Likewise.
+ * lib/gl_map.h (gl_map_create_empty, gl_map_nx_create_empty): Add
+ comment that deallocation must happen through 'gl_map_free'.
+ * lib/gl_xmap.h (gl_map_create_empty): Likewise.
+ * lib/gl_omap.h (gl_omap_create_empty, gl_omap_nx_create_empty): Add
+ comment that deallocation must happen through 'gl_omap_free'.
+ * lib/gl_xomap.h (gl_omap_create_empty): Likewise.
+
2021-08-07 Bruno Haible <bruno@clisp.org>
xgetdomainname: Improve GCC 11 allocation-deallocation checking.
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_listelement_dispose_fn dispose_fn,
- bool allow_duplicates);
+ bool allow_duplicates)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_t gl_list_nx_create_empty (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_listelement_dispose_fn dispose_fn,
- bool allow_duplicates);
+ bool allow_duplicates)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/;
/* Creates a list with given contents.
IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST,
gl_listelement_hashcode_fn hashcode_fn,
gl_listelement_dispose_fn dispose_fn,
bool allow_duplicates,
- size_t count, const void **contents);
+ size_t count, const void **contents)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_t gl_list_nx_create (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_listelement_dispose_fn dispose_fn,
bool allow_duplicates,
- size_t count, const void **contents);
+ size_t count, const void **contents)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/;
/* Returns the current number of elements in a list. */
extern size_t gl_list_size (gl_list_t list);
/* Define all functions of this file as accesses to the
struct gl_list_implementation. */
-GL_LIST_INLINE gl_list_t
+GL_LIST_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+gl_list_t
gl_list_nx_create_empty (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
allow_duplicates);
}
-GL_LIST_INLINE gl_list_t
+GL_LIST_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+gl_list_t
gl_list_nx_create (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_mapkey_equals_fn equals_fn,
gl_mapkey_hashcode_fn hashcode_fn,
gl_mapkey_dispose_fn kdispose_fn,
- gl_mapvalue_dispose_fn vdispose_fn);
+ gl_mapvalue_dispose_fn vdispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_map_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_map_t gl_map_nx_create_empty (gl_map_implementation_t implementation,
gl_mapkey_equals_fn equals_fn,
gl_mapkey_hashcode_fn hashcode_fn,
gl_mapkey_dispose_fn kdispose_fn,
- gl_mapvalue_dispose_fn vdispose_fn);
+ gl_mapvalue_dispose_fn vdispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_map_free, 1)*/;
/* Returns the current number of pairs in a map. */
extern size_t gl_map_size (gl_map_t map);
/* Define most functions of this file as accesses to the
struct gl_map_implementation. */
-GL_MAP_INLINE gl_map_t
+GL_MAP_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_map_free, 1)*/
+gl_map_t
gl_map_nx_create_empty (gl_map_implementation_t implementation,
gl_mapkey_equals_fn equals_fn,
gl_mapkey_hashcode_fn hashcode_fn,
extern gl_omap_t gl_omap_create_empty (gl_omap_implementation_t implementation,
gl_mapkey_compar_fn compar_fn,
gl_mapkey_dispose_fn kdispose_fn,
- gl_mapvalue_dispose_fn vdispose_fn);
+ gl_mapvalue_dispose_fn vdispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_omap_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_omap_t gl_omap_nx_create_empty (gl_omap_implementation_t implementation,
gl_mapkey_compar_fn compar_fn,
gl_mapkey_dispose_fn kdispose_fn,
- gl_mapvalue_dispose_fn vdispose_fn);
+ gl_mapvalue_dispose_fn vdispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_omap_free, 1)*/;
/* Returns the current number of pairs in an ordered map. */
extern size_t gl_omap_size (gl_omap_t map);
/* Define most functions of this file as accesses to the
struct gl_omap_implementation. */
-GL_OMAP_INLINE gl_omap_t
+GL_OMAP_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_omap_free, 1)*/
+gl_omap_t
gl_omap_nx_create_empty (gl_omap_implementation_t implementation,
gl_mapkey_compar_fn compar_fn,
gl_mapkey_dispose_fn kdispose_fn,
/* declared in gl_xoset.h */
extern gl_oset_t gl_oset_create_empty (gl_oset_implementation_t implementation,
gl_setelement_compar_fn compar_fn,
- gl_setelement_dispose_fn dispose_fn);
+ gl_setelement_dispose_fn dispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_oset_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_oset_t gl_oset_nx_create_empty (gl_oset_implementation_t implementation,
gl_setelement_compar_fn compar_fn,
- gl_setelement_dispose_fn dispose_fn);
+ gl_setelement_dispose_fn dispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_oset_free, 1)*/;
/* Returns the current number of elements in an ordered set. */
extern size_t gl_oset_size (gl_oset_t set);
/* Define all functions of this file as accesses to the
struct gl_oset_implementation. */
-GL_OSET_INLINE gl_oset_t
+GL_OSET_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_oset_free, 1)*/
+gl_oset_t
gl_oset_nx_create_empty (gl_oset_implementation_t implementation,
gl_setelement_compar_fn compar_fn,
gl_setelement_dispose_fn dispose_fn)
extern gl_set_t gl_set_create_empty (gl_set_implementation_t implementation,
gl_setelement_equals_fn equals_fn,
gl_setelement_hashcode_fn hashcode_fn,
- gl_setelement_dispose_fn dispose_fn);
+ gl_setelement_dispose_fn dispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_set_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_set_t gl_set_nx_create_empty (gl_set_implementation_t implementation,
gl_setelement_equals_fn equals_fn,
gl_setelement_hashcode_fn hashcode_fn,
- gl_setelement_dispose_fn dispose_fn);
+ gl_setelement_dispose_fn dispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_set_free, 1)*/;
/* Returns the current number of elements in a set. */
extern size_t gl_set_size (gl_set_t set);
/* Define all functions of this file as accesses to the
struct gl_set_implementation. */
-GL_SET_INLINE gl_set_t
+GL_SET_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_set_free, 1)*/
+gl_set_t
gl_set_nx_create_empty (gl_set_implementation_t implementation,
gl_setelement_equals_fn equals_fn,
gl_setelement_hashcode_fn hashcode_fn,
*/
#if 0 /* declared in gl_xsublist.h */
extern gl_list_t gl_sublist_create (gl_list_t whole_list,
- size_t start_index, size_t end_index);
+ size_t start_index, size_t end_index)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
#endif
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_t gl_sublist_nx_create (gl_list_t whole_list,
- size_t start_index, size_t end_index);
+ size_t start_index, size_t end_index)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/;
#ifdef __cplusplus
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_listelement_dispose_fn dispose_fn,
- bool allow_duplicates);
+ bool allow_duplicates)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
extern gl_list_t gl_list_create (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_listelement_dispose_fn dispose_fn,
bool allow_duplicates,
- size_t count, const void **contents);
+ size_t count, const void **contents)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node,
const void *elt);
extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position,
const void *elt);
#endif
-GL_XLIST_INLINE gl_list_t
+GL_XLIST_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+_GL_ATTRIBUTE_RETURNS_NONNULL
+gl_list_t
gl_list_create_empty (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
return result;
}
-GL_XLIST_INLINE gl_list_t
+GL_XLIST_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+_GL_ATTRIBUTE_RETURNS_NONNULL
+gl_list_t
gl_list_create (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_mapkey_equals_fn equals_fn,
gl_mapkey_hashcode_fn hashcode_fn,
gl_mapkey_dispose_fn kdispose_fn,
- gl_mapvalue_dispose_fn vdispose_fn);
+ gl_mapvalue_dispose_fn vdispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_map_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
extern bool gl_map_put (gl_map_t map, const void *key, const void *value);
extern bool gl_map_getput (gl_map_t map, const void *key, const void *value,
const void **oldvaluep);
#endif
-GL_XMAP_INLINE gl_map_t
+GL_XMAP_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_map_free, 1)*/
+_GL_ATTRIBUTE_RETURNS_NONNULL
+gl_map_t
gl_map_create_empty (gl_map_implementation_t implementation,
gl_mapkey_equals_fn equals_fn,
gl_mapkey_hashcode_fn hashcode_fn,
extern gl_omap_t gl_omap_create_empty (gl_omap_implementation_t implementation,
gl_mapkey_compar_fn compar_fn,
gl_mapkey_dispose_fn kdispose_fn,
- gl_mapvalue_dispose_fn vdispose_fn);
+ gl_mapvalue_dispose_fn vdispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_omap_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
extern bool gl_omap_put (gl_omap_t map, const void *key, const void *value);
extern bool gl_omap_getput (gl_omap_t map, const void *key, const void *value,
const void **oldvaluep);
#endif
-GL_XOMAP_INLINE gl_omap_t
+GL_XOMAP_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_omap_free, 1)*/
+_GL_ATTRIBUTE_RETURNS_NONNULL
+gl_omap_t
gl_omap_create_empty (gl_omap_implementation_t implementation,
gl_mapkey_compar_fn compar_fn,
gl_mapkey_dispose_fn kdispose_fn,
#if 0 /* These are defined inline below. */
extern gl_oset_t gl_oset_create_empty (gl_oset_implementation_t implementation,
gl_setelement_compar_fn compar_fn,
- gl_setelement_dispose_fn dispose_fn);
+ gl_setelement_dispose_fn dispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_oset_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
extern bool gl_oset_add (gl_oset_t set, const void *elt);
#endif
-GL_XOSET_INLINE gl_oset_t
+GL_XOSET_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_oset_free, 1)*/
+_GL_ATTRIBUTE_RETURNS_NONNULL
+gl_oset_t
gl_oset_create_empty (gl_oset_implementation_t implementation,
gl_setelement_compar_fn compar_fn,
gl_setelement_dispose_fn dispose_fn)
extern gl_set_t gl_set_create_empty (gl_set_implementation_t implementation,
gl_setelement_equals_fn equals_fn,
gl_setelement_hashcode_fn hashcode_fn,
- gl_setelement_dispose_fn dispose_fn);
+ gl_setelement_dispose_fn dispose_fn)
+ /*_GL_ATTRIBUTE_DEALLOC (gl_set_free, 1)*/
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
extern bool gl_set_add (gl_set_t set, const void *elt);
#endif
-GL_XSET_INLINE gl_set_t
+GL_XSET_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_set_free, 1)*/
+_GL_ATTRIBUTE_RETURNS_NONNULL
+gl_set_t
gl_set_create_empty (gl_set_implementation_t implementation,
gl_setelement_equals_fn equals_fn,
gl_setelement_hashcode_fn hashcode_fn,
/* These functions are thin wrappers around the corresponding functions with
_nx_ infix from gl_sublist.h. Upon out-of-memory, they invoke
xalloc_die (), instead of returning an error indicator. */
-GL_XSUBLIST_INLINE gl_list_t
+GL_XSUBLIST_INLINE
+/*_GL_ATTRIBUTE_DEALLOC (gl_list_free, 1)*/
+_GL_ATTRIBUTE_RETURNS_NONNULL
+gl_list_t
gl_sublist_create (gl_list_t whole_list, size_t start_index, size_t end_index)
{
gl_list_t result = gl_sublist_nx_create (whole_list, start_index, end_index);