]> Savannah Git Hosting - gnulib.git/commitdiff
xstrndup: Improve GCC 11 allocation-deallocation checking.
authorBruno Haible <bruno@clisp.org>
Sat, 7 Aug 2021 21:15:21 +0000 (23:15 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 7 Aug 2021 21:15:21 +0000 (23:15 +0200)
* lib/xstrndup.h: Include <stdlib.h> instead of <stddef.h>.
(xstrndup): Declare that deallocation must happen through 'free'.

ChangeLog
lib/xstrndup.h

index 7dccacbb46750837f9debecafc9a7a6c890b94e0..8e3707f0462826fa8d2352bb1eda08d9979f81a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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'.
+
 2021-08-07  Bruno Haible  <bruno@clisp.org>
 
        xstriconveh: Improve GCC 11 allocation-deallocation checking.
index 7fbbf2c1b988467f07419690808caa4c1dd95c11..dc4f6e273ec8901d0087a0ebcdc8fdd4ae22bc28 100644 (file)
    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;