]> Savannah Git Hosting - gnulib.git/commitdiff
pagalign_alloc: improve -fanalyzer malloc checking
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 2 Aug 2021 00:38:29 +0000 (17:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 2 Aug 2021 01:06:55 +0000 (18:06 -0700)
ChangeLog
lib/pagealign_alloc.h

index f130f9317ed3bae73c6a08d046588e8dad0b3618..e3573cee27e1b9cd60132399c544dbf93c938d9d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,7 +4,7 @@
        * lib/backup-internal.h, lib/backupfile.h:
        * lib/canonicalize.h, lib/dfa.h, lib/dirname.h, lib/exclude.h:
        * lib/filenamecat.h, lib/malloca.h, lib/modechange.h:
-       * lib/mountlist.h:
+       * lib/mountlist.h, lib/pagealign_alloc.h:
        Add malloc-related attributes and include stdlib.h as needed.
        * lib/dfa.c: Include verify.h.
        (assume_nonnull): New macro.
index 387d5aa04511f0148756261a3c546519794147df..eb2d4e0df24cc735747771c1b93759c0cfb34a37 100644 (file)
 
 # include <stddef.h>
 
+/* Free a memory block.
+   PTR must be a non-NULL pointer returned by pagealign_alloc or
+   pagealign_xalloc.  */
+extern void pagealign_free (void *ptr)
+  _GL_ATTRIBUTE_NONNULL ((1));
+
 /* Allocate a block of memory of SIZE bytes, aligned on a system page
    boundary.
    If SIZE is not a multiple of the system page size, it will be rounded up
    Return a pointer to the start of the memory block. Upon allocation failure,
    return NULL and set errno.  */
 extern void *pagealign_alloc (size_t size)
-     _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (pagealign_free, 1)
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 
 /* Like pagealign_alloc, except it exits the program if the allocation
    fails.  */
 extern void *pagealign_xalloc (size_t size)
-     _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
-
-/* Free a memory block.
-   PTR must be a non-NULL pointer returned by pagealign_alloc or
-   pagealign_xalloc.  */
-extern void pagealign_free (void *ptr);
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (pagealign_free, 1)
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
 
 #endif /* _PAGEALIGN_ALLOC_H */