X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/9e0e57c7d64492351f4a7ce1c01054d4d43a1bcc..a7517f0fdec7aa1172f9bb41a9d61cf1b02b286d:/lib/allocator.h diff --git a/lib/allocator.h b/lib/allocator.h index 4ac863b224..0904b32154 100644 --- a/lib/allocator.h +++ b/lib/allocator.h @@ -1,6 +1,6 @@ /* Memory allocators such as malloc+free. - Copyright (C) 2011 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ /* Written by Paul Eggert. */ #ifndef _GL_ALLOCATOR_H +#define _GL_ALLOCATOR_H #include @@ -30,24 +31,28 @@ struct allocator attributes do not work with pointers to functions. See . */ - /* Call MALLOC to allocate memory, like 'malloc'. On failure MALLOC + /* Call ALLOCATE to allocate memory, like 'malloc'. On failure ALLOCATE should return NULL, though not necessarily set errno. When given a zero size it may return NULL even if successful. */ - void *(*malloc) (size_t); + void *(*allocate) (size_t); - /* If nonnull, call REALLOC to reallocate memory, like 'realloc'. - On failure REALLOC should return NULL, though not necessarily set + /* If nonnull, call REALLOCATE to reallocate memory, like 'realloc'. + On failure REALLOCATE should return NULL, though not necessarily set errno. When given a zero size it may return NULL even if successful. */ - void *(*realloc) (void *, size_t); + void *(*reallocate) (void *, size_t); /* Call FREE to free memory, like 'free'. */ void (*free) (void *); - /* 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); + /* If nonnull, call DIE (SIZE) if MALLOC (SIZE) or REALLOC (..., + SIZE) fails. DIE should not return. SIZE should equal SIZE_MAX + if size_t overflow was detected while calculating sizes to be + passed to MALLOC or REALLOC. */ + void (*die) (size_t); }; -#endif +/* An allocator using the stdlib functions and a null DIE function. */ +extern struct allocator const stdlib_allocator; + +#endif /* _GL_ALLOCATOR_H */