summaryrefslogtreecommitdiff
path: root/lib/allocator.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-04-05 11:19:19 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-04-05 11:19:19 -0700
commit9e0e57c7d64492351f4a7ce1c01054d4d43a1bcc (patch)
treec60da8b92b2258e8d73fd27063275c8524b19932 /lib/allocator.h
parentca23cc8840efb1354ebe16c6bb99bf1f8880e9b6 (diff)
downloademacs-9e0e57c7d64492351f4a7ce1c01054d4d43a1bcc.tar.gz
Merge changes from gnulib.
Diffstat (limited to 'lib/allocator.h')
-rw-r--r--lib/allocator.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/allocator.h b/lib/allocator.h
index 54cc5ff66f0..4ac863b224c 100644
--- a/lib/allocator.h
+++ b/lib/allocator.h
@@ -21,8 +21,15 @@
#include <stddef.h>
+/* An object describing a memory allocator family. */
+
struct allocator
{
+ /* Do not use GCC attributes such as __attribute__ ((malloc)) with
+ the function types pointed at by these members, because these
+ attributes do not work with pointers to functions. See
+ <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00007.html>. */
+
/* Call MALLOC to allocate memory, like 'malloc'. On failure MALLOC
should return NULL, though not necessarily set errno. When given
a zero size it may return NULL even if successful. */
@@ -37,8 +44,9 @@ struct allocator
/* Call FREE to free memory, like 'free'. */
void (*free) (void *);
- /* If nonnull, call DIE if MALLOC or REALLOC fails. DIE should
- not return. */
+ /* If nonnull, call DIE if MALLOC or REALLOC fails. DIE should not
+ return. DIE can be used by code that detects memory overflow
+ while calculating sizes to be passed to MALLOC or REALLOC. */
void (*die) (void);
};