bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read-file: Improve GCC 11 allocation-deallocation checking


From: Bruno Haible
Subject: read-file: Improve GCC 11 allocation-deallocation checking
Date: Sat, 07 Aug 2021 21:53:39 +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>

        read-file: Improve GCC 11 allocation-deallocation checking.
        * lib/read-file.h: Include <stdlib.h> instead of <stddef.h>.
        (fread_file, read_file): Declare that deallocation must happen through
        'free'.

diff --git a/lib/read-file.h b/lib/read-file.h
index 9a96684..688f802 100644
--- a/lib/read-file.h
+++ b/lib/read-file.h
@@ -18,8 +18,8 @@
 #ifndef READ_FILE_H
 #define READ_FILE_H
 
-/* Get size_t.  */
-#include <stddef.h>
+/* Get size_t, free().  */
+#include <stdlib.h>
 
 /* Get FILE.  */
 #include <stdio.h>
@@ -30,8 +30,10 @@
 /* Indicate that the file content contains sensitive information.  */
 #define RF_SENSITIVE 0x2
 
-extern char *fread_file (FILE * stream, int flags, size_t * length);
+extern char *fread_file (FILE * stream, int flags, size_t * length)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
 
-extern char *read_file (const char *filename, int flags, size_t * length);
+extern char *read_file (const char *filename, int flags, size_t * length)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
 
 #endif /* READ_FILE_H */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]