diff options
| author | Paul Eggert | 2014-05-22 09:40:35 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-05-22 09:40:35 -0700 |
| commit | 74fde0f44f68a14d920db4d24626984e2964368d (patch) | |
| tree | ce487b5a0080a9a9abbef810f93bb19069defe95 /src/gmalloc.c | |
| parent | bbd03f131a88ab1ff993bb6bba1bea93e7ee17ea (diff) | |
| download | emacs-74fde0f44f68a14d920db4d24626984e2964368d.tar.gz emacs-74fde0f44f68a14d920db4d24626984e2964368d.zip | |
Supply malloc and alloc_size attributes for extern allocators.
This documents the C API, and helps GCC generate a bit better code.
* conf_post.h (ATTRIBUTE_MALLOC, ATTRIBUTE_ALLOC_SIZE)
(ATTRIBUTE_MALLOC_SIZE): New macros.
* gmalloc.c (malloc, realloc, calloc):
* gtkutil.h (malloc_widget_value):
* lisp.h (ralloc, r_re_alloc, xmalloc, xzalloc, xrealloc, xnmalloc)
(xnrealloc, xstrdup, xlispstrdup, record_xmalloc):
Use them.
Diffstat (limited to 'src/gmalloc.c')
| -rw-r--r-- | src/gmalloc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c index 977abbdbbbd..ab1dfd07db2 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -51,12 +51,12 @@ extern "C" | |||
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | /* Allocate SIZE bytes of memory. */ | 53 | /* Allocate SIZE bytes of memory. */ |
| 54 | extern void *malloc (size_t size); | 54 | extern void *malloc (size_t size) ATTRIBUTE_MALLOC_SIZE ((1)); |
| 55 | /* Re-allocate the previously allocated block | 55 | /* Re-allocate the previously allocated block |
| 56 | in ptr, making the new block SIZE bytes long. */ | 56 | in ptr, making the new block SIZE bytes long. */ |
| 57 | extern void *realloc (void *ptr, size_t size); | 57 | extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2)); |
| 58 | /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ | 58 | /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ |
| 59 | extern void *calloc (size_t nmemb, size_t size); | 59 | extern void *calloc (size_t nmemb, size_t size) ATTRIBUTE_MALLOC_SIZE ((1,2)); |
| 60 | /* Free a block allocated by `malloc', `realloc' or `calloc'. */ | 60 | /* Free a block allocated by `malloc', `realloc' or `calloc'. */ |
| 61 | extern void free (void *ptr); | 61 | extern void free (void *ptr); |
| 62 | 62 | ||