From cb57db513b3b5e2c5e09d197e63d6a921188d599 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 27 May 2022 11:27:08 -0700 Subject: [PATCH] Add ATTRIBUTE_DEALLOC to extern functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This can help static checking. It’s not as important for static functions, where GCC can figure this stuff out own its own. * src/sysstdio.h (emacs_fopen): Add ATTRIBUTE_DEALLOC (fclose, 1). * src/tparam.h (tparam): Add ATTRIBUTE_DEALLOC_FREE. Include stdlib.h so that ‘free’ is declared. * src/xterm.h (x_get_atom_name): Add ATTRIBUTE_DEALLOC_FREE. --- src/sysstdio.h | 3 ++- src/tparam.h | 5 ++++- src/xterm.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sysstdio.h b/src/sysstdio.h index 727a466be52..efedc3e450b 100644 --- a/src/sysstdio.h +++ b/src/sysstdio.h @@ -28,7 +28,8 @@ along with GNU Emacs. If not, see . */ #include #include -extern FILE *emacs_fopen (char const *, char const *) ATTRIBUTE_MALLOC; +extern FILE *emacs_fopen (char const *, char const *) + ATTRIBUTE_MALLOC ATTRIBUTE_DEALLOC (fclose, 1); extern void errputc (int); extern void errwrite (void const *, ptrdiff_t); extern void close_output_streams (void); diff --git a/src/tparam.h b/src/tparam.h index 653f01bdde0..4f4bdc8820f 100644 --- a/src/tparam.h +++ b/src/tparam.h @@ -20,6 +20,8 @@ along with GNU Emacs. If not, see . */ #ifndef EMACS_TPARAM_H #define EMACS_TPARAM_H +#include + #include /* Don't try to include termcap.h. On some systems, configure finds a @@ -32,7 +34,8 @@ int tgetnum (const char *); char *tgetstr (const char *, char **); char *tgoto (const char *, int, int); -char *tparam (const char *, char *, int, int, int, int, int) ATTRIBUTE_MALLOC; +char *tparam (const char *, char *, int, int, int, int, int) + ATTRIBUTE_MALLOC ATTRIBUTE_DEALLOC_FREE; extern char PC; extern char *BC; diff --git a/src/xterm.h b/src/xterm.h index 329fa4c84f6..283d4fa9b11 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -1542,7 +1542,7 @@ extern void x_own_selection (Lisp_Object, Lisp_Object, Lisp_Object); extern Atom x_intern_cached_atom (struct x_display_info *, const char *, bool); extern char *x_get_atom_name (struct x_display_info *, Atom, bool *) - ATTRIBUTE_MALLOC; + ATTRIBUTE_MALLOC ATTRIBUTE_DEALLOC_FREE; #ifdef USE_GTK extern bool xg_set_icon (struct frame *, Lisp_Object); -- 2.39.2