diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2012-08-03 16:36:11 -0700 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-08-03 16:36:11 -0700 |
| commit | 98c6f1e36ff487925280fa0b0340af9d058632b5 (patch) | |
| tree | 5601a2ac9433883b753a36f8d9c15f9d9d0b0eec /src/lisp.h | |
| parent | 8834c57aab03fb7ea9d92f9e995844ff7ce64b7b (diff) | |
| download | emacs-98c6f1e36ff487925280fa0b0340af9d058632b5.tar.gz | |
Remove unnecessary casts involving pointers.
These casts are no longer needed now that we assume C89 or later,
since they involve casting to or from void *.
* alloc.c (make_pure_string, make_pure_c_string, pure_cons)
(make_pure_float, make_pure_vector):
* lisp.h (SAFE_ALLOCA, SAFE_ALLOCA_LISP):
* macros.c (Fstart_kbd_macro):
* menu.c (find_and_return_menu_selection):
* minibuf.c (read_minibuf_noninteractive):
* sysdep.c (closedir):
* xdisp.c (x_produce_glyphs):
* xfaces.c (compare_fonts_by_sort_order):
* xfns.c (x_real_positions, select_visual):
* xselect.c (x_stop_queuing_selection_requests)
(x_get_window_property, x_get_window_property_as_lisp_data):
* xterm.c (x_set_frame_alpha, x_find_modifier_meanings):
Remove unnecessary pointer casts.
* alloc.c (record_xmalloc): New function.
* lisp.h (record_xmalloc): New decl.
(SAFE_ALLOCA): Now takes just one arg -- the size -- and acts
more like a function. This is because the pointer cast is not
needed. All uses changed.
* print.c (print_string, print_error_message): Avoid length recalc.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/lisp.h b/src/lisp.h index e77b76005cd..4a538045a80 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3441,24 +3441,16 @@ static char const DIRECTORY_SEP = '/'; enum MAX_ALLOCA { MAX_ALLOCA = 16*1024 }; extern Lisp_Object safe_alloca_unwind (Lisp_Object); +extern void *record_xmalloc (size_t); #define USE_SAFE_ALLOCA \ ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0 /* SAFE_ALLOCA allocates a simple buffer. */ -#define SAFE_ALLOCA(buf, type, size) \ - do { \ - if ((size) < MAX_ALLOCA) \ - buf = (type) alloca (size); \ - else \ - { \ - buf = xmalloc (size); \ - sa_must_free = 1; \ - record_unwind_protect (safe_alloca_unwind, \ - make_save_value (buf, 0)); \ - } \ - } while (0) +#define SAFE_ALLOCA(size) ((size) < MAX_ALLOCA \ + ? alloca (size) \ + : (sa_must_free = 1, record_xmalloc (size))) /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER * NITEMS items, each of the same type as *BUF. MULTIPLIER must @@ -3493,7 +3485,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); #define SAFE_ALLOCA_LISP(buf, nelt) \ do { \ if ((nelt) < MAX_ALLOCA / sizeof (Lisp_Object)) \ - buf = (Lisp_Object *) alloca ((nelt) * sizeof (Lisp_Object)); \ + buf = alloca ((nelt) * sizeof (Lisp_Object)); \ else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ { \ Lisp_Object arg_; \ |
