[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
xstrndup: Improve GCC 11 allocation-deallocation checking
From: |
Bruno Haible |
Subject: |
xstrndup: Improve GCC 11 allocation-deallocation checking |
Date: |
Sat, 07 Aug 2021 23:16:08 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) |
2021-08-07 Bruno Haible <bruno@clisp.org>
xstrndup: Improve GCC 11 allocation-deallocation checking.
* lib/xstrndup.h: Include <stdlib.h> instead of <stddef.h>.
(xstrndup): Declare that deallocation must happen through 'free'.
diff --git a/lib/xstrndup.h b/lib/xstrndup.h
index 7fbbf2c..dc4f6e2 100644
--- a/lib/xstrndup.h
+++ b/lib/xstrndup.h
@@ -15,9 +15,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
-#include <stddef.h>
+#include <stdlib.h>
/* Return a newly allocated copy of at most N bytes of STRING.
In other words, return a copy of the initial segment of length N of
STRING. */
-extern char *xstrndup (const char *string, size_t n) _GL_ATTRIBUTE_MALLOC;
+extern char *xstrndup (const char *string, size_t n)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- xstrndup: Improve GCC 11 allocation-deallocation checking,
Bruno Haible <=