]> Savannah Git Hosting - gnulib.git/commitdiff
string: Avoid syntax error re strdup in string.in.h (regr. 2021-09-07).
authorBruno Haible <bruno@clisp.org>
Sun, 24 Oct 2021 22:34:24 +0000 (00:34 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 24 Oct 2021 22:46:12 +0000 (00:46 +0200)
Reported by Jan Engelhardt <jengelh@inai.de>
and by Arash Esbati <arash@gnu.org> via Andy Moreton in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-10/msg00058.html>.

* lib/string.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
_GL_ATTRIBUTE_MALLOC): Add fallback declarations, like in
lib/stdlib.in.h.
* lib/wchar.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
_GL_ATTRIBUTE_MALLOC): Likewise.

ChangeLog
lib/string.in.h
lib/wchar.in.h

index 2f19e30a2a20104f3ce8e7d9e2def121603979af..6aaa53991801d57e96611279bc3b0e101d2d2e91 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2021-10-24  Bruno Haible  <bruno@clisp.org>
+
+       string: Avoid syntax error re strdup in string.in.h (regr. 2021-09-07).
+       Reported by Jan Engelhardt <jengelh@inai.de>
+       and by Arash Esbati <arash@gnu.org> via Andy Moreton in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2021-10/msg00058.html>.
+       * lib/string.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
+       _GL_ATTRIBUTE_MALLOC): Add fallback declarations, like in
+       lib/stdlib.in.h.
+       * lib/wchar.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
+       _GL_ATTRIBUTE_MALLOC): Likewise.
+
 2021-10-19  Paul Eggert  <eggert@cs.ucla.edu>
 
        xalloc: new function xinmalloc
index 8d77ae380001c366505cc7415d71a60bdf76c185..afe735086777418e3c1c025a47f308fb8d7eabd2 100644 (file)
 # include <strings.h>
 #endif
 
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+#  define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+   can be freed via 'free'; it can be used only after declaring 'free'.  */
+/* Applies to: functions.  Cannot be used on inline functions.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+   allocated memory.  */
+/* Applies to: functions.  */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE
index f13379ad84e77367aacc48bb85915941237e0a42..20315dd7bbd1bfb9057e6137ab5fd7dda2dfbb1c 100644 (file)
 #ifndef _@GUARD_PREFIX@_WCHAR_H
 #define _@GUARD_PREFIX@_WCHAR_H
 
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+#  define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+   can be freed via 'free'; it can be used only after declaring 'free'.  */
+/* Applies to: functions.  Cannot be used on inline functions.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+   allocated memory.  */
+/* Applies to: functions.  */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE