2021-08-07  Bruno Haible  <[email protected]>

        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;


Reply via email to