aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2014-05-22 09:40:35 -0700
committerPaul Eggert2014-05-22 09:40:35 -0700
commit74fde0f44f68a14d920db4d24626984e2964368d (patch)
treece487b5a0080a9a9abbef810f93bb19069defe95 /src/lisp.h
parentbbd03f131a88ab1ff993bb6bba1bea93e7ee17ea (diff)
downloademacs-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/lisp.h')
-rw-r--r--src/lisp.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 67b26ef91c7..40dd03c4fc4 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3755,9 +3755,9 @@ INLINE void (check_cons_list) (void) { lisp_h_check_cons_list (); }
3755 3755
3756#ifdef REL_ALLOC 3756#ifdef REL_ALLOC
3757/* Defined in ralloc.c. */ 3757/* Defined in ralloc.c. */
3758extern void *r_alloc (void **, size_t); 3758extern void *r_alloc (void **, size_t) ATTRIBUTE_ALLOC_SIZE ((2));
3759extern void r_alloc_free (void **); 3759extern void r_alloc_free (void **);
3760extern void *r_re_alloc (void **, size_t); 3760extern void *r_re_alloc (void **, size_t) ATTRIBUTE_ALLOC_SIZE ((2));
3761extern void r_alloc_reset_variable (void **, void **); 3761extern void r_alloc_reset_variable (void **, void **);
3762extern void r_alloc_inhibit_buffer_relocation (int); 3762extern void r_alloc_inhibit_buffer_relocation (int);
3763#endif 3763#endif
@@ -4391,16 +4391,17 @@ extern bool initialized;
4391/* True means ^G can quit instantly. */ 4391/* True means ^G can quit instantly. */
4392extern bool immediate_quit; 4392extern bool immediate_quit;
4393 4393
4394extern void *xmalloc (size_t); 4394extern void *xmalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1));
4395extern void *xzalloc (size_t); 4395extern void *xzalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1));
4396extern void *xrealloc (void *, size_t); 4396extern void *xrealloc (void *, size_t) ATTRIBUTE_ALLOC_SIZE ((2));
4397extern void xfree (void *); 4397extern void xfree (void *);
4398extern void *xnmalloc (ptrdiff_t, ptrdiff_t); 4398extern void *xnmalloc (ptrdiff_t, ptrdiff_t) ATTRIBUTE_MALLOC_SIZE ((1,2));
4399extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t); 4399extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t)
4400 ATTRIBUTE_ALLOC_SIZE ((2,3));
4400extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t); 4401extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t);
4401 4402
4402extern char *xstrdup (const char *); 4403extern char *xstrdup (const char *) ATTRIBUTE_MALLOC;
4403extern char *xlispstrdup (Lisp_Object); 4404extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC;
4404extern void dupstring (char **, char const *); 4405extern void dupstring (char **, char const *);
4405extern void xputenv (const char *); 4406extern void xputenv (const char *);
4406 4407
@@ -4432,7 +4433,7 @@ extern void init_system_name (void);
4432 4433
4433enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 }; 4434enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 };
4434 4435
4435extern void *record_xmalloc (size_t); 4436extern void *record_xmalloc (size_t) ATTRIBUTE_ALLOC_SIZE ((1));
4436 4437
4437#define USE_SAFE_ALLOCA \ 4438#define USE_SAFE_ALLOCA \
4438 ptrdiff_t sa_count = SPECPDL_INDEX (); bool sa_must_free = false 4439 ptrdiff_t sa_count = SPECPDL_INDEX (); bool sa_must_free = false