1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Memory allocators such as malloc+free.
5 Copyright (C) 2011-2013 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* Written by Paul Eggert. */
22 #ifndef _GL_ALLOCATOR_H
23 #define _GL_ALLOCATOR_H
27 /* An object describing a memory allocator family. */
31 /* Do not use GCC attributes such as __attribute__ ((malloc)) with
32 the function types pointed at by these members, because these
33 attributes do not work with pointers to functions. See
34 <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00007.html>. */
36 /* Call ALLOCATE to allocate memory, like 'malloc'. On failure ALLOCATE
37 should return NULL, though not necessarily set errno. When given
38 a zero size it may return NULL even if successful. */
39 void *(*allocate) (size_t);
41 /* If nonnull, call REALLOCATE to reallocate memory, like 'realloc'.
42 On failure REALLOCATE should return NULL, though not necessarily set
43 errno. When given a zero size it may return NULL even if
45 void *(*reallocate) (void *, size_t);
47 /* Call FREE to free memory, like 'free'. */
48 void (*free) (void *);
50 /* If nonnull, call DIE (SIZE) if MALLOC (SIZE) or REALLOC (...,
51 SIZE) fails. DIE should not return. SIZE should equal SIZE_MAX
52 if size_t overflow was detected while calculating sizes to be
53 passed to MALLOC or REALLOC. */
57 /* An allocator using the stdlib functions and a null DIE function. */
58 extern struct allocator const stdlib_allocator;
60 #endif /* _GL_ALLOCATOR_H */