diff options
| author | Paul Eggert | 2012-08-03 16:36:11 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-08-03 16:36:11 -0700 |
| commit | 98c6f1e36ff487925280fa0b0340af9d058632b5 (patch) | |
| tree | 5601a2ac9433883b753a36f8d9c15f9d9d0b0eec /src | |
| parent | 8834c57aab03fb7ea9d92f9e995844ff7ce64b7b (diff) | |
| download | emacs-98c6f1e36ff487925280fa0b0340af9d058632b5.tar.gz emacs-98c6f1e36ff487925280fa0b0340af9d058632b5.zip | |
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')
| -rw-r--r-- | src/ChangeLog | 24 | ||||
| -rw-r--r-- | src/alloc.c | 36 | ||||
| -rw-r--r-- | src/callproc.c | 10 | ||||
| -rw-r--r-- | src/casefiddle.c | 5 | ||||
| -rw-r--r-- | src/character.c | 6 | ||||
| -rw-r--r-- | src/charset.c | 12 | ||||
| -rw-r--r-- | src/data.c | 3 | ||||
| -rw-r--r-- | src/dired.c | 3 | ||||
| -rw-r--r-- | src/doc.c | 2 | ||||
| -rw-r--r-- | src/doprnt.c | 7 | ||||
| -rw-r--r-- | src/editfns.c | 16 | ||||
| -rw-r--r-- | src/fileio.c | 2 | ||||
| -rw-r--r-- | src/filelock.c | 35 | ||||
| -rw-r--r-- | src/fns.c | 14 | ||||
| -rw-r--r-- | src/font.c | 2 | ||||
| -rw-r--r-- | src/frame.c | 6 | ||||
| -rw-r--r-- | src/keyboard.c | 4 | ||||
| -rw-r--r-- | src/keymap.c | 5 | ||||
| -rw-r--r-- | src/lisp.h | 18 | ||||
| -rw-r--r-- | src/lread.c | 8 | ||||
| -rw-r--r-- | src/macros.c | 4 | ||||
| -rw-r--r-- | src/menu.c | 3 | ||||
| -rw-r--r-- | src/minibuf.c | 2 | ||||
| -rw-r--r-- | src/print.c | 14 | ||||
| -rw-r--r-- | src/sysdep.c | 2 | ||||
| -rw-r--r-- | src/w32menu.c | 9 | ||||
| -rw-r--r-- | src/xdisp.c | 21 | ||||
| -rw-r--r-- | src/xfaces.c | 6 | ||||
| -rw-r--r-- | src/xfns.c | 4 | ||||
| -rw-r--r-- | src/xfont.c | 4 | ||||
| -rw-r--r-- | src/xselect.c | 10 | ||||
| -rw-r--r-- | src/xterm.c | 4 |
32 files changed, 143 insertions, 158 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4aa0dcb022e..c3868f521ea 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,29 @@ | |||
| 1 | 2012-08-03 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-08-03 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Remove unnecessary casts involving pointers. | ||
| 4 | These casts are no longer needed now that we assume C89 or later, | ||
| 5 | since they involve casting to or from void *. | ||
| 6 | * alloc.c (make_pure_string, make_pure_c_string, pure_cons) | ||
| 7 | (make_pure_float, make_pure_vector): | ||
| 8 | * lisp.h (SAFE_ALLOCA, SAFE_ALLOCA_LISP): | ||
| 9 | * macros.c (Fstart_kbd_macro): | ||
| 10 | * menu.c (find_and_return_menu_selection): | ||
| 11 | * minibuf.c (read_minibuf_noninteractive): | ||
| 12 | * sysdep.c (closedir): | ||
| 13 | * xdisp.c (x_produce_glyphs): | ||
| 14 | * xfaces.c (compare_fonts_by_sort_order): | ||
| 15 | * xfns.c (x_real_positions, select_visual): | ||
| 16 | * xselect.c (x_stop_queuing_selection_requests) | ||
| 17 | (x_get_window_property, x_get_window_property_as_lisp_data): | ||
| 18 | * xterm.c (x_set_frame_alpha, x_find_modifier_meanings): | ||
| 19 | Remove unnecessary pointer casts. | ||
| 20 | * alloc.c (record_xmalloc): New function. | ||
| 21 | * lisp.h (record_xmalloc): New decl. | ||
| 22 | (SAFE_ALLOCA): Now takes just one arg -- the size -- and acts | ||
| 23 | more like a function. This is because the pointer cast is not | ||
| 24 | needed. All uses changed. | ||
| 25 | * print.c (print_string, print_error_message): Avoid length recalc. | ||
| 26 | |||
| 3 | Improve fix for macroexp crash with debugging (Bug#12118). | 27 | Improve fix for macroexp crash with debugging (Bug#12118). |
| 4 | * lisp.h (ASET) [ENABLE_CHECKING]: Pay attention to | 28 | * lisp.h (ASET) [ENABLE_CHECKING]: Pay attention to |
| 5 | ARRAY_MARK_FLAG when checking subscripts, because ASET is | 29 | ARRAY_MARK_FLAG when checking subscripts, because ASET is |
diff --git a/src/alloc.c b/src/alloc.c index aef68a1c070..3939e704978 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -898,6 +898,16 @@ safe_alloca_unwind (Lisp_Object arg) | |||
| 898 | return Qnil; | 898 | return Qnil; |
| 899 | } | 899 | } |
| 900 | 900 | ||
| 901 | /* Return a newly allocated memory block of SIZE bytes, remembering | ||
| 902 | to free it when unwinding. */ | ||
| 903 | void * | ||
| 904 | record_xmalloc (size_t size) | ||
| 905 | { | ||
| 906 | void *p = xmalloc (size); | ||
| 907 | record_unwind_protect (safe_alloca_unwind, make_save_value (p, 0)); | ||
| 908 | return p; | ||
| 909 | } | ||
| 910 | |||
| 901 | 911 | ||
| 902 | /* Like malloc but used for allocating Lisp data. NBYTES is the | 912 | /* Like malloc but used for allocating Lisp data. NBYTES is the |
| 903 | number of bytes to allocate, TYPE describes the intended use of the | 913 | number of bytes to allocate, TYPE describes the intended use of the |
| @@ -5210,13 +5220,11 @@ make_pure_string (const char *data, | |||
| 5210 | ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) | 5220 | ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) |
| 5211 | { | 5221 | { |
| 5212 | Lisp_Object string; | 5222 | Lisp_Object string; |
| 5213 | struct Lisp_String *s; | 5223 | struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String); |
| 5214 | |||
| 5215 | s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); | ||
| 5216 | s->data = (unsigned char *) find_string_data_in_pure (data, nbytes); | 5224 | s->data = (unsigned char *) find_string_data_in_pure (data, nbytes); |
| 5217 | if (s->data == NULL) | 5225 | if (s->data == NULL) |
| 5218 | { | 5226 | { |
| 5219 | s->data = (unsigned char *) pure_alloc (nbytes + 1, -1); | 5227 | s->data = pure_alloc (nbytes + 1, -1); |
| 5220 | memcpy (s->data, data, nbytes); | 5228 | memcpy (s->data, data, nbytes); |
| 5221 | s->data[nbytes] = '\0'; | 5229 | s->data[nbytes] = '\0'; |
| 5222 | } | 5230 | } |
| @@ -5234,9 +5242,7 @@ Lisp_Object | |||
| 5234 | make_pure_c_string (const char *data, ptrdiff_t nchars) | 5242 | make_pure_c_string (const char *data, ptrdiff_t nchars) |
| 5235 | { | 5243 | { |
| 5236 | Lisp_Object string; | 5244 | Lisp_Object string; |
| 5237 | struct Lisp_String *s; | 5245 | struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String); |
| 5238 | |||
| 5239 | s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); | ||
| 5240 | s->size = nchars; | 5246 | s->size = nchars; |
| 5241 | s->size_byte = -1; | 5247 | s->size_byte = -1; |
| 5242 | s->data = (unsigned char *) data; | 5248 | s->data = (unsigned char *) data; |
| @@ -5251,10 +5257,8 @@ make_pure_c_string (const char *data, ptrdiff_t nchars) | |||
| 5251 | Lisp_Object | 5257 | Lisp_Object |
| 5252 | pure_cons (Lisp_Object car, Lisp_Object cdr) | 5258 | pure_cons (Lisp_Object car, Lisp_Object cdr) |
| 5253 | { | 5259 | { |
| 5254 | register Lisp_Object new; | 5260 | Lisp_Object new; |
| 5255 | struct Lisp_Cons *p; | 5261 | struct Lisp_Cons *p = pure_alloc (sizeof *p, Lisp_Cons); |
| 5256 | |||
| 5257 | p = (struct Lisp_Cons *) pure_alloc (sizeof *p, Lisp_Cons); | ||
| 5258 | XSETCONS (new, p); | 5262 | XSETCONS (new, p); |
| 5259 | XSETCAR (new, Fpurecopy (car)); | 5263 | XSETCAR (new, Fpurecopy (car)); |
| 5260 | XSETCDR (new, Fpurecopy (cdr)); | 5264 | XSETCDR (new, Fpurecopy (cdr)); |
| @@ -5267,10 +5271,8 @@ pure_cons (Lisp_Object car, Lisp_Object cdr) | |||
| 5267 | static Lisp_Object | 5271 | static Lisp_Object |
| 5268 | make_pure_float (double num) | 5272 | make_pure_float (double num) |
| 5269 | { | 5273 | { |
| 5270 | register Lisp_Object new; | 5274 | Lisp_Object new; |
| 5271 | struct Lisp_Float *p; | 5275 | struct Lisp_Float *p = pure_alloc (sizeof *p, Lisp_Float); |
| 5272 | |||
| 5273 | p = (struct Lisp_Float *) pure_alloc (sizeof *p, Lisp_Float); | ||
| 5274 | XSETFLOAT (new, p); | 5276 | XSETFLOAT (new, p); |
| 5275 | XFLOAT_INIT (new, num); | 5277 | XFLOAT_INIT (new, num); |
| 5276 | return new; | 5278 | return new; |
| @@ -5284,10 +5286,8 @@ static Lisp_Object | |||
| 5284 | make_pure_vector (ptrdiff_t len) | 5286 | make_pure_vector (ptrdiff_t len) |
| 5285 | { | 5287 | { |
| 5286 | Lisp_Object new; | 5288 | Lisp_Object new; |
| 5287 | struct Lisp_Vector *p; | ||
| 5288 | size_t size = header_size + len * word_size; | 5289 | size_t size = header_size + len * word_size; |
| 5289 | 5290 | struct Lisp_Vector *p = pure_alloc (size, Lisp_Vectorlike); | |
| 5290 | p = (struct Lisp_Vector *) pure_alloc (size, Lisp_Vectorlike); | ||
| 5291 | XSETVECTOR (new, p); | 5291 | XSETVECTOR (new, p); |
| 5292 | XVECTOR (new)->header.size = len; | 5292 | XVECTOR (new)->header.size = len; |
| 5293 | return new; | 5293 | return new; |
diff --git a/src/callproc.c b/src/callproc.c index facca887772..5eabd689188 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -427,8 +427,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 427 | && SREF (path, 1) == ':') | 427 | && SREF (path, 1) == ':') |
| 428 | path = Fsubstring (path, make_number (2), Qnil); | 428 | path = Fsubstring (path, make_number (2), Qnil); |
| 429 | 429 | ||
| 430 | SAFE_ALLOCA (new_argv, const unsigned char **, | 430 | new_argv = SAFE_ALLOCA ((nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); |
| 431 | (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); | ||
| 432 | if (nargs > 4) | 431 | if (nargs > 4) |
| 433 | { | 432 | { |
| 434 | ptrdiff_t i; | 433 | ptrdiff_t i; |
| @@ -978,8 +977,7 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r | |||
| 978 | Lisp_Object coding_systems; | 977 | Lisp_Object coding_systems; |
| 979 | Lisp_Object val, *args2; | 978 | Lisp_Object val, *args2; |
| 980 | ptrdiff_t i; | 979 | ptrdiff_t i; |
| 981 | char *tempfile; | 980 | Lisp_Object tmpdir; |
| 982 | Lisp_Object tmpdir, pattern; | ||
| 983 | 981 | ||
| 984 | if (STRINGP (Vtemporary_file_directory)) | 982 | if (STRINGP (Vtemporary_file_directory)) |
| 985 | tmpdir = Vtemporary_file_directory; | 983 | tmpdir = Vtemporary_file_directory; |
| @@ -1003,8 +1001,8 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r | |||
| 1003 | 1001 | ||
| 1004 | { | 1002 | { |
| 1005 | USE_SAFE_ALLOCA; | 1003 | USE_SAFE_ALLOCA; |
| 1006 | pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir); | 1004 | Lisp_Object pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir); |
| 1007 | SAFE_ALLOCA (tempfile, char *, SBYTES (pattern) + 1); | 1005 | char *tempfile = SAFE_ALLOCA (SBYTES (pattern) + 1); |
| 1008 | memcpy (tempfile, SDATA (pattern), SBYTES (pattern) + 1); | 1006 | memcpy (tempfile, SDATA (pattern), SBYTES (pattern) + 1); |
| 1009 | coding_systems = Qt; | 1007 | coding_systems = Qt; |
| 1010 | 1008 | ||
diff --git a/src/casefiddle.c b/src/casefiddle.c index 19fbc832288..81e84252b72 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c | |||
| @@ -114,12 +114,11 @@ casify_object (enum case_action flag, Lisp_Object obj) | |||
| 114 | ptrdiff_t i, i_byte, size = SCHARS (obj); | 114 | ptrdiff_t i, i_byte, size = SCHARS (obj); |
| 115 | int len; | 115 | int len; |
| 116 | USE_SAFE_ALLOCA; | 116 | USE_SAFE_ALLOCA; |
| 117 | unsigned char *dst, *o; | ||
| 118 | ptrdiff_t o_size = (size < STRING_BYTES_BOUND / MAX_MULTIBYTE_LENGTH | 117 | ptrdiff_t o_size = (size < STRING_BYTES_BOUND / MAX_MULTIBYTE_LENGTH |
| 119 | ? size * MAX_MULTIBYTE_LENGTH | 118 | ? size * MAX_MULTIBYTE_LENGTH |
| 120 | : STRING_BYTES_BOUND); | 119 | : STRING_BYTES_BOUND); |
| 121 | SAFE_ALLOCA (dst, void *, o_size); | 120 | unsigned char *dst = SAFE_ALLOCA (o_size); |
| 122 | o = dst; | 121 | unsigned char *o = dst; |
| 123 | 122 | ||
| 124 | for (i = i_byte = 0; i < size; i++, i_byte += len) | 123 | for (i = i_byte = 0; i < size; i++, i_byte += len) |
| 125 | { | 124 | { |
diff --git a/src/character.c b/src/character.c index 093f63d8ba7..bdb0eead740 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -920,12 +920,10 @@ usage: (unibyte-string &rest BYTES) */) | |||
| 920 | (ptrdiff_t n, Lisp_Object *args) | 920 | (ptrdiff_t n, Lisp_Object *args) |
| 921 | { | 921 | { |
| 922 | ptrdiff_t i; | 922 | ptrdiff_t i; |
| 923 | unsigned char *buf, *p; | ||
| 924 | Lisp_Object str; | 923 | Lisp_Object str; |
| 925 | USE_SAFE_ALLOCA; | 924 | USE_SAFE_ALLOCA; |
| 926 | 925 | unsigned char *buf = SAFE_ALLOCA (n); | |
| 927 | SAFE_ALLOCA (buf, unsigned char *, n); | 926 | unsigned char *p = buf; |
| 928 | p = buf; | ||
| 929 | 927 | ||
| 930 | for (i = 0; i < n; i++) | 928 | for (i = 0; i < n; i++) |
| 931 | { | 929 | { |
diff --git a/src/charset.c b/src/charset.c index 0054854e80e..fbbcefc4915 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -503,8 +503,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int co | |||
| 503 | 503 | ||
| 504 | /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is | 504 | /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is |
| 505 | large (larger than MAX_ALLOCA). */ | 505 | large (larger than MAX_ALLOCA). */ |
| 506 | SAFE_ALLOCA (head, struct charset_map_entries *, | 506 | head = SAFE_ALLOCA (sizeof *head); |
| 507 | sizeof (struct charset_map_entries)); | ||
| 508 | entries = head; | 507 | entries = head; |
| 509 | memset (entries, 0, sizeof (struct charset_map_entries)); | 508 | memset (entries, 0, sizeof (struct charset_map_entries)); |
| 510 | 509 | ||
| @@ -535,8 +534,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int co | |||
| 535 | 534 | ||
| 536 | if (n_entries > 0 && (n_entries % 0x10000) == 0) | 535 | if (n_entries > 0 && (n_entries % 0x10000) == 0) |
| 537 | { | 536 | { |
| 538 | SAFE_ALLOCA (entries->next, struct charset_map_entries *, | 537 | entries->next = SAFE_ALLOCA (sizeof *entries->next); |
| 539 | sizeof (struct charset_map_entries)); | ||
| 540 | entries = entries->next; | 538 | entries = entries->next; |
| 541 | memset (entries, 0, sizeof (struct charset_map_entries)); | 539 | memset (entries, 0, sizeof (struct charset_map_entries)); |
| 542 | n_entries = 0; | 540 | n_entries = 0; |
| @@ -572,8 +570,7 @@ load_charset_map_from_vector (struct charset *charset, Lisp_Object vec, int cont | |||
| 572 | 570 | ||
| 573 | /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is | 571 | /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is |
| 574 | large (larger than MAX_ALLOCA). */ | 572 | large (larger than MAX_ALLOCA). */ |
| 575 | SAFE_ALLOCA (head, struct charset_map_entries *, | 573 | head = SAFE_ALLOCA (sizeof *head); |
| 576 | sizeof (struct charset_map_entries)); | ||
| 577 | entries = head; | 574 | entries = head; |
| 578 | memset (entries, 0, sizeof (struct charset_map_entries)); | 575 | memset (entries, 0, sizeof (struct charset_map_entries)); |
| 579 | 576 | ||
| @@ -604,8 +601,7 @@ load_charset_map_from_vector (struct charset *charset, Lisp_Object vec, int cont | |||
| 604 | 601 | ||
| 605 | if (n_entries > 0 && (n_entries % 0x10000) == 0) | 602 | if (n_entries > 0 && (n_entries % 0x10000) == 0) |
| 606 | { | 603 | { |
| 607 | SAFE_ALLOCA (entries->next, struct charset_map_entries *, | 604 | entries->next = SAFE_ALLOCA (sizeof *entries->next); |
| 608 | sizeof (struct charset_map_entries)); | ||
| 609 | entries = entries->next; | 605 | entries = entries->next; |
| 610 | memset (entries, 0, sizeof (struct charset_map_entries)); | 606 | memset (entries, 0, sizeof (struct charset_map_entries)); |
| 611 | } | 607 | } |
diff --git a/src/data.c b/src/data.c index 4c6f7fe3eae..f5942a84da1 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -2179,10 +2179,9 @@ bool-vector. IDX starts at 0. */) | |||
| 2179 | { | 2179 | { |
| 2180 | /* We must relocate the string data. */ | 2180 | /* We must relocate the string data. */ |
| 2181 | ptrdiff_t nchars = SCHARS (array); | 2181 | ptrdiff_t nchars = SCHARS (array); |
| 2182 | unsigned char *str; | ||
| 2183 | USE_SAFE_ALLOCA; | 2182 | USE_SAFE_ALLOCA; |
| 2183 | unsigned char *str = SAFE_ALLOCA (nbytes); | ||
| 2184 | 2184 | ||
| 2185 | SAFE_ALLOCA (str, unsigned char *, nbytes); | ||
| 2186 | memcpy (str, SDATA (array), nbytes); | 2185 | memcpy (str, SDATA (array), nbytes); |
| 2187 | allocate_string_data (XSTRING (array), nchars, | 2186 | allocate_string_data (XSTRING (array), nchars, |
| 2188 | nbytes + new_bytes - prev_bytes); | 2187 | nbytes + new_bytes - prev_bytes); |
diff --git a/src/dired.c b/src/dired.c index 7c047f97e6f..771230717e3 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -810,9 +810,8 @@ file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_ad | |||
| 810 | ptrdiff_t len = NAMLEN (dp); | 810 | ptrdiff_t len = NAMLEN (dp); |
| 811 | ptrdiff_t pos = SCHARS (dirname); | 811 | ptrdiff_t pos = SCHARS (dirname); |
| 812 | int value; | 812 | int value; |
| 813 | char *fullname; | ||
| 814 | USE_SAFE_ALLOCA; | 813 | USE_SAFE_ALLOCA; |
| 815 | SAFE_ALLOCA (fullname, char *, len + pos + 2); | 814 | char *fullname = SAFE_ALLOCA (len + pos + 2); |
| 816 | 815 | ||
| 817 | #ifdef MSDOS | 816 | #ifdef MSDOS |
| 818 | /* Some fields of struct stat are *very* expensive to compute on MS-DOS, | 817 | /* Some fields of struct stat are *very* expensive to compute on MS-DOS, |
| @@ -123,7 +123,7 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition) | |||
| 123 | /* sizeof ("../etc/") == 8 */ | 123 | /* sizeof ("../etc/") == 8 */ |
| 124 | if (minsize < 8) | 124 | if (minsize < 8) |
| 125 | minsize = 8; | 125 | minsize = 8; |
| 126 | SAFE_ALLOCA (name, char *, minsize + SCHARS (file) + 8); | 126 | name = SAFE_ALLOCA (minsize + SCHARS (file) + 8); |
| 127 | strcpy (name, SSDATA (docdir)); | 127 | strcpy (name, SSDATA (docdir)); |
| 128 | strcat (name, SSDATA (file)); | 128 | strcat (name, SSDATA (file)); |
| 129 | } | 129 | } |
diff --git a/src/doprnt.c b/src/doprnt.c index 44dc641d5dd..63f05cb74e2 100644 --- a/src/doprnt.c +++ b/src/doprnt.c | |||
| @@ -161,10 +161,9 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, | |||
| 161 | if (format_end == 0) | 161 | if (format_end == 0) |
| 162 | format_end = format + strlen (format); | 162 | format_end = format + strlen (format); |
| 163 | 163 | ||
| 164 | if (format_end - format < sizeof (fixed_buffer) - 1) | 164 | fmtcpy = (format_end - format < sizeof (fixed_buffer) - 1 |
| 165 | fmtcpy = fixed_buffer; | 165 | ? fixed_buffer |
| 166 | else | 166 | : SAFE_ALLOCA (format_end - format + 1)); |
| 167 | SAFE_ALLOCA (fmtcpy, char *, format_end - format + 1); | ||
| 168 | 167 | ||
| 169 | bufsize--; | 168 | bufsize--; |
| 170 | 169 | ||
diff --git a/src/editfns.c b/src/editfns.c index e657b3ec532..f86b4c12f58 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1793,7 +1793,7 @@ format_time_string (char const *format, ptrdiff_t formatlen, | |||
| 1793 | if (STRING_BYTES_BOUND <= len) | 1793 | if (STRING_BYTES_BOUND <= len) |
| 1794 | string_overflow (); | 1794 | string_overflow (); |
| 1795 | size = len + 1; | 1795 | size = len + 1; |
| 1796 | SAFE_ALLOCA (buf, char *, size); | 1796 | buf = SAFE_ALLOCA (size); |
| 1797 | } | 1797 | } |
| 1798 | 1798 | ||
| 1799 | UNBLOCK_INPUT; | 1799 | UNBLOCK_INPUT; |
| @@ -2072,7 +2072,7 @@ the data it can't find. */) | |||
| 2072 | int m = offset / 60; | 2072 | int m = offset / 60; |
| 2073 | int am = offset < 0 ? - m : m; | 2073 | int am = offset < 0 ? - m : m; |
| 2074 | char buf[sizeof "+00" + INT_STRLEN_BOUND (int)]; | 2074 | char buf[sizeof "+00" + INT_STRLEN_BOUND (int)]; |
| 2075 | zone_name = make_formatted_string (buf, "%c%02d%02d", | 2075 | zone_name = make_formatted_string (buf, "%c%02d%02d", |
| 2076 | (offset < 0 ? '-' : '+'), | 2076 | (offset < 0 ? '-' : '+'), |
| 2077 | am / 60, am % 60); | 2077 | am / 60, am % 60); |
| 2078 | } | 2078 | } |
| @@ -3686,7 +3686,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3686 | ptrdiff_t i; | 3686 | ptrdiff_t i; |
| 3687 | if ((SIZE_MAX - formatlen) / sizeof (struct info) <= nargs) | 3687 | if ((SIZE_MAX - formatlen) / sizeof (struct info) <= nargs) |
| 3688 | memory_full (SIZE_MAX); | 3688 | memory_full (SIZE_MAX); |
| 3689 | SAFE_ALLOCA (info, struct info *, (nargs + 1) * sizeof *info + formatlen); | 3689 | info = SAFE_ALLOCA ((nargs + 1) * sizeof *info + formatlen); |
| 3690 | discarded = (char *) &info[nargs + 1]; | 3690 | discarded = (char *) &info[nargs + 1]; |
| 3691 | for (i = 0; i < nargs + 1; i++) | 3691 | for (i = 0; i < nargs + 1; i++) |
| 3692 | { | 3692 | { |
| @@ -4645,7 +4645,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4645 | { | 4645 | { |
| 4646 | USE_SAFE_ALLOCA; | 4646 | USE_SAFE_ALLOCA; |
| 4647 | 4647 | ||
| 4648 | SAFE_ALLOCA (temp, unsigned char *, len2_byte); | 4648 | temp = SAFE_ALLOCA (len2_byte); |
| 4649 | 4649 | ||
| 4650 | /* Don't precompute these addresses. We have to compute them | 4650 | /* Don't precompute these addresses. We have to compute them |
| 4651 | at the last minute, because the relocating allocator might | 4651 | at the last minute, because the relocating allocator might |
| @@ -4663,7 +4663,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4663 | { | 4663 | { |
| 4664 | USE_SAFE_ALLOCA; | 4664 | USE_SAFE_ALLOCA; |
| 4665 | 4665 | ||
| 4666 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); | 4666 | temp = SAFE_ALLOCA (len1_byte); |
| 4667 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4667 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4668 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4668 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4669 | memcpy (temp, start1_addr, len1_byte); | 4669 | memcpy (temp, start1_addr, len1_byte); |
| @@ -4703,7 +4703,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4703 | if (!NULL_INTERVAL_P (tmp_interval3)) | 4703 | if (!NULL_INTERVAL_P (tmp_interval3)) |
| 4704 | set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3); | 4704 | set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3); |
| 4705 | 4705 | ||
| 4706 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); | 4706 | temp = SAFE_ALLOCA (len1_byte); |
| 4707 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4707 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4708 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4708 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4709 | memcpy (temp, start1_addr, len1_byte); | 4709 | memcpy (temp, start1_addr, len1_byte); |
| @@ -4733,7 +4733,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4733 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); | 4733 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); |
| 4734 | 4734 | ||
| 4735 | /* holds region 2 */ | 4735 | /* holds region 2 */ |
| 4736 | SAFE_ALLOCA (temp, unsigned char *, len2_byte); | 4736 | temp = SAFE_ALLOCA (len2_byte); |
| 4737 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4737 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4738 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4738 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4739 | memcpy (temp, start2_addr, len2_byte); | 4739 | memcpy (temp, start2_addr, len2_byte); |
| @@ -4766,7 +4766,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4766 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); | 4766 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); |
| 4767 | 4767 | ||
| 4768 | /* holds region 1 */ | 4768 | /* holds region 1 */ |
| 4769 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); | 4769 | temp = SAFE_ALLOCA (len1_byte); |
| 4770 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4770 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4771 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4771 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4772 | memcpy (temp, start1_addr, len1_byte); | 4772 | memcpy (temp, start1_addr, len1_byte); |
diff --git a/src/fileio.c b/src/fileio.c index 44710323192..9578f1f9f1a 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -5200,7 +5200,7 @@ auto_save_error (Lisp_Object error_val) | |||
| 5200 | msg = Fformat (3, args); | 5200 | msg = Fformat (3, args); |
| 5201 | GCPRO1 (msg); | 5201 | GCPRO1 (msg); |
| 5202 | nbytes = SBYTES (msg); | 5202 | nbytes = SBYTES (msg); |
| 5203 | SAFE_ALLOCA (msgbuf, char *, nbytes); | 5203 | msgbuf = SAFE_ALLOCA (nbytes); |
| 5204 | memcpy (msgbuf, SDATA (msg), nbytes); | 5204 | memcpy (msgbuf, SDATA (msg), nbytes); |
| 5205 | 5205 | ||
| 5206 | for (i = 0; i < 3; ++i) | 5206 | for (i = 0; i < 3; ++i) |
diff --git a/src/filelock.c b/src/filelock.c index e840d3c5c3b..d21d8e7ba02 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -337,31 +337,22 @@ fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn) | |||
| 337 | static int | 337 | static int |
| 338 | lock_file_1 (char *lfname, int force) | 338 | lock_file_1 (char *lfname, int force) |
| 339 | { | 339 | { |
| 340 | register int err; | 340 | int err; |
| 341 | printmax_t boot, pid; | ||
| 342 | const char *user_name; | ||
| 343 | const char *host_name; | ||
| 344 | char *lock_info_str; | ||
| 345 | ptrdiff_t lock_info_size; | ||
| 346 | int symlink_errno; | 341 | int symlink_errno; |
| 347 | USE_SAFE_ALLOCA; | 342 | USE_SAFE_ALLOCA; |
| 348 | 343 | ||
| 349 | /* Call this first because it can GC. */ | 344 | /* Call this first because it can GC. */ |
| 350 | boot = get_boot_time (); | 345 | printmax_t boot = get_boot_time (); |
| 351 | 346 | ||
| 352 | if (STRINGP (Fuser_login_name (Qnil))) | 347 | Lisp_Object luser_name = Fuser_login_name (Qnil); |
| 353 | user_name = SSDATA (Fuser_login_name (Qnil)); | 348 | char const *user_name = STRINGP (luser_name) ? SSDATA (luser_name) : ""; |
| 354 | else | 349 | Lisp_Object lhost_name = Fsystem_name (); |
| 355 | user_name = ""; | 350 | char const *host_name = STRINGP (lhost_name) ? SSDATA (lhost_name) : ""; |
| 356 | if (STRINGP (Fsystem_name ())) | 351 | ptrdiff_t lock_info_size = (strlen (user_name) + strlen (host_name) |
| 357 | host_name = SSDATA (Fsystem_name ()); | 352 | + 2 * INT_STRLEN_BOUND (printmax_t) |
| 358 | else | 353 | + sizeof "@.:"); |
| 359 | host_name = ""; | 354 | char *lock_info_str = SAFE_ALLOCA (lock_info_size); |
| 360 | lock_info_size = (strlen (user_name) + strlen (host_name) | 355 | printmax_t pid = getpid (); |
| 361 | + 2 * INT_STRLEN_BOUND (printmax_t) | ||
| 362 | + sizeof "@.:"); | ||
| 363 | SAFE_ALLOCA (lock_info_str, char *, lock_info_size); | ||
| 364 | pid = getpid (); | ||
| 365 | 356 | ||
| 366 | esprintf (lock_info_str, boot ? "%s@%s.%"pMd":%"pMd : "%s@%s.%"pMd, | 357 | esprintf (lock_info_str, boot ? "%s@%s.%"pMd":%"pMd : "%s@%s.%"pMd, |
| 367 | user_name, host_name, pid, boot); | 358 | user_name, host_name, pid, boot); |
| @@ -593,7 +584,7 @@ lock_file (Lisp_Object fn) | |||
| 593 | locker_size = (strlen (lock_info.user) + strlen (lock_info.host) | 584 | locker_size = (strlen (lock_info.user) + strlen (lock_info.host) |
| 594 | + INT_STRLEN_BOUND (printmax_t) | 585 | + INT_STRLEN_BOUND (printmax_t) |
| 595 | + sizeof "@ (pid )"); | 586 | + sizeof "@ (pid )"); |
| 596 | SAFE_ALLOCA (locker, char *, locker_size); | 587 | locker = SAFE_ALLOCA (locker_size); |
| 597 | pid = lock_info.pid; | 588 | pid = lock_info.pid; |
| 598 | esprintf (locker, "%s@%s (pid %"pMd")", | 589 | esprintf (locker, "%s@%s (pid %"pMd")", |
| 599 | lock_info.user, lock_info.host, pid); | 590 | lock_info.user, lock_info.host, pid); |
| @@ -903,7 +903,7 @@ string_make_multibyte (Lisp_Object string) | |||
| 903 | if (nbytes == SBYTES (string)) | 903 | if (nbytes == SBYTES (string)) |
| 904 | return string; | 904 | return string; |
| 905 | 905 | ||
| 906 | SAFE_ALLOCA (buf, unsigned char *, nbytes); | 906 | buf = SAFE_ALLOCA (nbytes); |
| 907 | copy_text (SDATA (string), buf, SBYTES (string), | 907 | copy_text (SDATA (string), buf, SBYTES (string), |
| 908 | 0, 1); | 908 | 0, 1); |
| 909 | 909 | ||
| @@ -935,7 +935,7 @@ string_to_multibyte (Lisp_Object string) | |||
| 935 | if (nbytes == SBYTES (string)) | 935 | if (nbytes == SBYTES (string)) |
| 936 | return make_multibyte_string (SSDATA (string), nbytes, nbytes); | 936 | return make_multibyte_string (SSDATA (string), nbytes, nbytes); |
| 937 | 937 | ||
| 938 | SAFE_ALLOCA (buf, unsigned char *, nbytes); | 938 | buf = SAFE_ALLOCA (nbytes); |
| 939 | memcpy (buf, SDATA (string), SBYTES (string)); | 939 | memcpy (buf, SDATA (string), SBYTES (string)); |
| 940 | str_to_multibyte (buf, nbytes, SBYTES (string)); | 940 | str_to_multibyte (buf, nbytes, SBYTES (string)); |
| 941 | 941 | ||
| @@ -961,7 +961,7 @@ string_make_unibyte (Lisp_Object string) | |||
| 961 | 961 | ||
| 962 | nchars = SCHARS (string); | 962 | nchars = SCHARS (string); |
| 963 | 963 | ||
| 964 | SAFE_ALLOCA (buf, unsigned char *, nchars); | 964 | buf = SAFE_ALLOCA (nchars); |
| 965 | copy_text (SDATA (string), buf, SBYTES (string), | 965 | copy_text (SDATA (string), buf, SBYTES (string), |
| 966 | 1, 0); | 966 | 1, 0); |
| 967 | 967 | ||
| @@ -2972,7 +2972,7 @@ into shorter lines. */) | |||
| 2972 | allength = length + length/3 + 1; | 2972 | allength = length + length/3 + 1; |
| 2973 | allength += allength / MIME_LINE_LENGTH + 1 + 6; | 2973 | allength += allength / MIME_LINE_LENGTH + 1 + 6; |
| 2974 | 2974 | ||
| 2975 | SAFE_ALLOCA (encoded, char *, allength); | 2975 | encoded = SAFE_ALLOCA (allength); |
| 2976 | encoded_length = base64_encode_1 ((char *) BYTE_POS_ADDR (ibeg), | 2976 | encoded_length = base64_encode_1 ((char *) BYTE_POS_ADDR (ibeg), |
| 2977 | encoded, length, NILP (no_line_break), | 2977 | encoded, length, NILP (no_line_break), |
| 2978 | !NILP (BVAR (current_buffer, enable_multibyte_characters))); | 2978 | !NILP (BVAR (current_buffer, enable_multibyte_characters))); |
| @@ -3027,7 +3027,7 @@ into shorter lines. */) | |||
| 3027 | allength += allength / MIME_LINE_LENGTH + 1 + 6; | 3027 | allength += allength / MIME_LINE_LENGTH + 1 + 6; |
| 3028 | 3028 | ||
| 3029 | /* We need to allocate enough room for decoding the text. */ | 3029 | /* We need to allocate enough room for decoding the text. */ |
| 3030 | SAFE_ALLOCA (encoded, char *, allength); | 3030 | encoded = SAFE_ALLOCA (allength); |
| 3031 | 3031 | ||
| 3032 | encoded_length = base64_encode_1 (SSDATA (string), | 3032 | encoded_length = base64_encode_1 (SSDATA (string), |
| 3033 | encoded, length, NILP (no_line_break), | 3033 | encoded, length, NILP (no_line_break), |
| @@ -3171,7 +3171,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */ | |||
| 3171 | working on a multibyte buffer, each decoded code may occupy at | 3171 | working on a multibyte buffer, each decoded code may occupy at |
| 3172 | most two bytes. */ | 3172 | most two bytes. */ |
| 3173 | allength = multibyte ? length * 2 : length; | 3173 | allength = multibyte ? length * 2 : length; |
| 3174 | SAFE_ALLOCA (decoded, char *, allength); | 3174 | decoded = SAFE_ALLOCA (allength); |
| 3175 | 3175 | ||
| 3176 | move_gap_both (XFASTINT (beg), ibeg); | 3176 | move_gap_both (XFASTINT (beg), ibeg); |
| 3177 | decoded_length = base64_decode_1 ((char *) BYTE_POS_ADDR (ibeg), | 3177 | decoded_length = base64_decode_1 ((char *) BYTE_POS_ADDR (ibeg), |
| @@ -3222,7 +3222,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string, | |||
| 3222 | 3222 | ||
| 3223 | length = SBYTES (string); | 3223 | length = SBYTES (string); |
| 3224 | /* We need to allocate enough room for decoding the text. */ | 3224 | /* We need to allocate enough room for decoding the text. */ |
| 3225 | SAFE_ALLOCA (decoded, char *, length); | 3225 | decoded = SAFE_ALLOCA (length); |
| 3226 | 3226 | ||
| 3227 | /* The decoded result should be unibyte. */ | 3227 | /* The decoded result should be unibyte. */ |
| 3228 | decoded_length = base64_decode_1 (SSDATA (string), decoded, length, | 3228 | decoded_length = base64_decode_1 (SSDATA (string), decoded, length, |
diff --git a/src/font.c b/src/font.c index b5e384140d8..c70c2abdc23 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -2227,7 +2227,7 @@ font_sort_entities (Lisp_Object list, Lisp_Object prefer, Lisp_Object frame, int | |||
| 2227 | maxlen = ASIZE (vec); | 2227 | maxlen = ASIZE (vec); |
| 2228 | } | 2228 | } |
| 2229 | 2229 | ||
| 2230 | SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * maxlen); | 2230 | data = SAFE_ALLOCA (maxlen * sizeof *data); |
| 2231 | best_score = 0xFFFFFFFF; | 2231 | best_score = 0xFFFFFFFF; |
| 2232 | best_entity = Qnil; | 2232 | best_entity = Qnil; |
| 2233 | 2233 | ||
diff --git a/src/frame.c b/src/frame.c index 9389eccb6f2..e43352d4e24 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -3697,8 +3697,6 @@ display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute, Lisp_Objec | |||
| 3697 | char * | 3697 | char * |
| 3698 | x_get_resource_string (const char *attribute, const char *class) | 3698 | x_get_resource_string (const char *attribute, const char *class) |
| 3699 | { | 3699 | { |
| 3700 | char *name_key; | ||
| 3701 | char *class_key; | ||
| 3702 | char *result; | 3700 | char *result; |
| 3703 | struct frame *sf = SELECTED_FRAME (); | 3701 | struct frame *sf = SELECTED_FRAME (); |
| 3704 | ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name); | 3702 | ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name); |
| @@ -3706,8 +3704,8 @@ x_get_resource_string (const char *attribute, const char *class) | |||
| 3706 | 3704 | ||
| 3707 | /* Allocate space for the components, the dots which separate them, | 3705 | /* Allocate space for the components, the dots which separate them, |
| 3708 | and the final '\0'. */ | 3706 | and the final '\0'. */ |
| 3709 | SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2); | 3707 | char *name_key = SAFE_ALLOCA (invocation_namelen + strlen (attribute) + 2); |
| 3710 | class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2); | 3708 | char *class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2); |
| 3711 | 3709 | ||
| 3712 | esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); | 3710 | esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); |
| 3713 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); | 3711 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); |
diff --git a/src/keyboard.c b/src/keyboard.c index 663a3956bf1..39112479eb7 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -6480,7 +6480,7 @@ modify_event_symbol (ptrdiff_t symbol_num, int modifiers, Lisp_Object symbol_kin | |||
| 6480 | ptrdiff_t len = (SBYTES (name_alist_or_stem) | 6480 | ptrdiff_t len = (SBYTES (name_alist_or_stem) |
| 6481 | + sizeof "-" + INT_STRLEN_BOUND (EMACS_INT)); | 6481 | + sizeof "-" + INT_STRLEN_BOUND (EMACS_INT)); |
| 6482 | USE_SAFE_ALLOCA; | 6482 | USE_SAFE_ALLOCA; |
| 6483 | SAFE_ALLOCA (buf, char *, len); | 6483 | buf = SAFE_ALLOCA (len); |
| 6484 | esprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem), | 6484 | esprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem), |
| 6485 | XINT (symbol_int) + 1); | 6485 | XINT (symbol_int) + 1); |
| 6486 | value = intern (buf); | 6486 | value = intern (buf); |
| @@ -7465,7 +7465,7 @@ menu_bar_items (Lisp_Object old) | |||
| 7465 | if (!NILP (Voverriding_local_map_menu_flag)) | 7465 | if (!NILP (Voverriding_local_map_menu_flag)) |
| 7466 | { | 7466 | { |
| 7467 | /* Yes, use them (if non-nil) as well as the global map. */ | 7467 | /* Yes, use them (if non-nil) as well as the global map. */ |
| 7468 | maps = (Lisp_Object *) alloca (3 * sizeof (maps[0])); | 7468 | maps = alloca (3 * sizeof (maps[0])); |
| 7469 | nmaps = 0; | 7469 | nmaps = 0; |
| 7470 | if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) | 7470 | if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) |
| 7471 | maps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map); | 7471 | maps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map); |
diff --git a/src/keymap.c b/src/keymap.c index ed8542249e5..ed65a5f3d8a 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2304,11 +2304,10 @@ around function keys and event symbols. */) | |||
| 2304 | { | 2304 | { |
| 2305 | if (NILP (no_angles)) | 2305 | if (NILP (no_angles)) |
| 2306 | { | 2306 | { |
| 2307 | char *buffer; | ||
| 2308 | Lisp_Object result; | 2307 | Lisp_Object result; |
| 2309 | USE_SAFE_ALLOCA; | 2308 | USE_SAFE_ALLOCA; |
| 2310 | SAFE_ALLOCA (buffer, char *, | 2309 | char *buffer = SAFE_ALLOCA (sizeof "<>" |
| 2311 | sizeof "<>" + SBYTES (SYMBOL_NAME (key))); | 2310 | + SBYTES (SYMBOL_NAME (key))); |
| 2312 | esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key))); | 2311 | esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key))); |
| 2313 | result = build_string (buffer); | 2312 | result = build_string (buffer); |
| 2314 | SAFE_FREE (); | 2313 | SAFE_FREE (); |
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 = '/'; | |||
| 3441 | enum MAX_ALLOCA { MAX_ALLOCA = 16*1024 }; | 3441 | enum MAX_ALLOCA { MAX_ALLOCA = 16*1024 }; |
| 3442 | 3442 | ||
| 3443 | extern Lisp_Object safe_alloca_unwind (Lisp_Object); | 3443 | extern Lisp_Object safe_alloca_unwind (Lisp_Object); |
| 3444 | extern void *record_xmalloc (size_t); | ||
| 3444 | 3445 | ||
| 3445 | #define USE_SAFE_ALLOCA \ | 3446 | #define USE_SAFE_ALLOCA \ |
| 3446 | ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0 | 3447 | ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0 |
| 3447 | 3448 | ||
| 3448 | /* SAFE_ALLOCA allocates a simple buffer. */ | 3449 | /* SAFE_ALLOCA allocates a simple buffer. */ |
| 3449 | 3450 | ||
| 3450 | #define SAFE_ALLOCA(buf, type, size) \ | 3451 | #define SAFE_ALLOCA(size) ((size) < MAX_ALLOCA \ |
| 3451 | do { \ | 3452 | ? alloca (size) \ |
| 3452 | if ((size) < MAX_ALLOCA) \ | 3453 | : (sa_must_free = 1, record_xmalloc (size))) |
| 3453 | buf = (type) alloca (size); \ | ||
| 3454 | else \ | ||
| 3455 | { \ | ||
| 3456 | buf = xmalloc (size); \ | ||
| 3457 | sa_must_free = 1; \ | ||
| 3458 | record_unwind_protect (safe_alloca_unwind, \ | ||
| 3459 | make_save_value (buf, 0)); \ | ||
| 3460 | } \ | ||
| 3461 | } while (0) | ||
| 3462 | 3454 | ||
| 3463 | /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER * | 3455 | /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER * |
| 3464 | NITEMS items, each of the same type as *BUF. MULTIPLIER must | 3456 | NITEMS items, each of the same type as *BUF. MULTIPLIER must |
| @@ -3493,7 +3485,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3493 | #define SAFE_ALLOCA_LISP(buf, nelt) \ | 3485 | #define SAFE_ALLOCA_LISP(buf, nelt) \ |
| 3494 | do { \ | 3486 | do { \ |
| 3495 | if ((nelt) < MAX_ALLOCA / sizeof (Lisp_Object)) \ | 3487 | if ((nelt) < MAX_ALLOCA / sizeof (Lisp_Object)) \ |
| 3496 | buf = (Lisp_Object *) alloca ((nelt) * sizeof (Lisp_Object)); \ | 3488 | buf = alloca ((nelt) * sizeof (Lisp_Object)); \ |
| 3497 | else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ | 3489 | else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ |
| 3498 | { \ | 3490 | { \ |
| 3499 | Lisp_Object arg_; \ | 3491 | Lisp_Object arg_; \ |
diff --git a/src/lread.c b/src/lread.c index d1549a34264..a31810ce463 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -4317,12 +4317,10 @@ dir_warning (const char *format, Lisp_Object dirname) | |||
| 4317 | /* Don't log the warning before we've initialized!! */ | 4317 | /* Don't log the warning before we've initialized!! */ |
| 4318 | if (initialized) | 4318 | if (initialized) |
| 4319 | { | 4319 | { |
| 4320 | char *buffer; | ||
| 4321 | ptrdiff_t message_len; | ||
| 4322 | USE_SAFE_ALLOCA; | 4320 | USE_SAFE_ALLOCA; |
| 4323 | SAFE_ALLOCA (buffer, char *, | 4321 | char *buffer = SAFE_ALLOCA (SBYTES (dirname) |
| 4324 | SBYTES (dirname) + strlen (format) - (sizeof "%s" - 1) + 1); | 4322 | + strlen (format) - (sizeof "%s" - 1) + 1); |
| 4325 | message_len = esprintf (buffer, format, SDATA (dirname)); | 4323 | ptrdiff_t message_len = esprintf (buffer, format, SDATA (dirname)); |
| 4326 | message_dolog (buffer, message_len, 0, STRING_MULTIBYTE (dirname)); | 4324 | message_dolog (buffer, message_len, 0, STRING_MULTIBYTE (dirname)); |
| 4327 | SAFE_FREE (); | 4325 | SAFE_FREE (); |
| 4328 | } | 4326 | } |
diff --git a/src/macros.c b/src/macros.c index 0b1eda0b8ab..a07d8ddbd23 100644 --- a/src/macros.c +++ b/src/macros.c | |||
| @@ -72,8 +72,8 @@ macro before appending to it. */) | |||
| 72 | if (current_kboard->kbd_macro_bufsize > 200) | 72 | if (current_kboard->kbd_macro_bufsize > 200) |
| 73 | { | 73 | { |
| 74 | current_kboard->kbd_macro_buffer | 74 | current_kboard->kbd_macro_buffer |
| 75 | = (Lisp_Object *)xrealloc (current_kboard->kbd_macro_buffer, | 75 | = xrealloc (current_kboard->kbd_macro_buffer, |
| 76 | 30 * sizeof (Lisp_Object)); | 76 | 30 * sizeof (Lisp_Object)); |
| 77 | current_kboard->kbd_macro_bufsize = 30; | 77 | current_kboard->kbd_macro_bufsize = 30; |
| 78 | } | 78 | } |
| 79 | current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer; | 79 | current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer; |
diff --git a/src/menu.c b/src/menu.c index 15029390137..eaf05ff3cba 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -976,8 +976,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) | |||
| 976 | 976 | ||
| 977 | prefix = entry = Qnil; | 977 | prefix = entry = Qnil; |
| 978 | i = 0; | 978 | i = 0; |
| 979 | subprefix_stack = | 979 | subprefix_stack = alloca (menu_items_used * sizeof (Lisp_Object)); |
| 980 | (Lisp_Object *)alloca (menu_items_used * sizeof (Lisp_Object)); | ||
| 981 | 980 | ||
| 982 | while (i < menu_items_used) | 981 | while (i < menu_items_used) |
| 983 | { | 982 | { |
diff --git a/src/minibuf.c b/src/minibuf.c index 4b9c0a32f85..cfe813f75f4 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -264,7 +264,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, | |||
| 264 | if (STRING_BYTES_BOUND / 2 < size) | 264 | if (STRING_BYTES_BOUND / 2 < size) |
| 265 | memory_full (SIZE_MAX); | 265 | memory_full (SIZE_MAX); |
| 266 | size *= 2; | 266 | size *= 2; |
| 267 | line = (char *) xrealloc (line, size); | 267 | line = xrealloc (line, size); |
| 268 | } | 268 | } |
| 269 | line[len++] = c; | 269 | line[len++] = c; |
| 270 | } | 270 | } |
diff --git a/src/print.c b/src/print.c index c4b96ff88ff..d1613390310 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -392,16 +392,14 @@ print_string (Lisp_Object string, Lisp_Object printcharfun) | |||
| 392 | { | 392 | { |
| 393 | /* Output to echo area. */ | 393 | /* Output to echo area. */ |
| 394 | ptrdiff_t nbytes = SBYTES (string); | 394 | ptrdiff_t nbytes = SBYTES (string); |
| 395 | char *buffer; | ||
| 396 | 395 | ||
| 397 | /* Copy the string contents so that relocation of STRING by | 396 | /* Copy the string contents so that relocation of STRING by |
| 398 | GC does not cause trouble. */ | 397 | GC does not cause trouble. */ |
| 399 | USE_SAFE_ALLOCA; | 398 | USE_SAFE_ALLOCA; |
| 400 | 399 | char *buffer = SAFE_ALLOCA (nbytes); | |
| 401 | SAFE_ALLOCA (buffer, char *, nbytes); | ||
| 402 | memcpy (buffer, SDATA (string), nbytes); | 400 | memcpy (buffer, SDATA (string), nbytes); |
| 403 | 401 | ||
| 404 | strout (buffer, chars, SBYTES (string), printcharfun); | 402 | strout (buffer, chars, nbytes, printcharfun); |
| 405 | 403 | ||
| 406 | SAFE_FREE (); | 404 | SAFE_FREE (); |
| 407 | } | 405 | } |
| @@ -862,11 +860,11 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, | |||
| 862 | if (!NILP (caller) && SYMBOLP (caller)) | 860 | if (!NILP (caller) && SYMBOLP (caller)) |
| 863 | { | 861 | { |
| 864 | Lisp_Object cname = SYMBOL_NAME (caller); | 862 | Lisp_Object cname = SYMBOL_NAME (caller); |
| 865 | char *name; | 863 | ptrdiff_t cnamelen = SBYTES (cname); |
| 866 | USE_SAFE_ALLOCA; | 864 | USE_SAFE_ALLOCA; |
| 867 | SAFE_ALLOCA (name, char *, SBYTES (cname)); | 865 | char *name = SAFE_ALLOCA (cnamelen); |
| 868 | memcpy (name, SDATA (cname), SBYTES (cname)); | 866 | memcpy (name, SDATA (cname), cnamelen); |
| 869 | message_dolog (name, SBYTES (cname), 0, 0); | 867 | message_dolog (name, cnamelen, 0, 0); |
| 870 | message_dolog (": ", 2, 0, 0); | 868 | message_dolog (": ", 2, 0, 0); |
| 871 | SAFE_FREE (); | 869 | SAFE_FREE (); |
| 872 | } | 870 | } |
diff --git a/src/sysdep.c b/src/sysdep.c index 4452298d103..d6bddd7a502 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2031,7 +2031,7 @@ closedir (DIR *dirp /* stream from opendir */) | |||
| 2031 | int rtnval; | 2031 | int rtnval; |
| 2032 | 2032 | ||
| 2033 | rtnval = emacs_close (dirp->dd_fd); | 2033 | rtnval = emacs_close (dirp->dd_fd); |
| 2034 | xfree ((char *) dirp); | 2034 | xfree (dirp); |
| 2035 | 2035 | ||
| 2036 | return rtnval; | 2036 | return rtnval; |
| 2037 | } | 2037 | } |
diff --git a/src/w32menu.c b/src/w32menu.c index d99516c8540..67bd575258e 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -1243,7 +1243,7 @@ simple_dialog_show (FRAME_PTR f, Lisp_Object contents, Lisp_Object header) | |||
| 1243 | one utf16 word, so we cannot simply use the character | 1243 | one utf16 word, so we cannot simply use the character |
| 1244 | length of temp. */ | 1244 | length of temp. */ |
| 1245 | int utf8_len = strlen (utf8_text); | 1245 | int utf8_len = strlen (utf8_text); |
| 1246 | SAFE_ALLOCA (text, WCHAR *, (utf8_len + 1) * sizeof (WCHAR)); | 1246 | text = SAFE_ALLOCA ((utf8_len + 1) * sizeof (WCHAR)); |
| 1247 | utf8to16 (utf8_text, utf8_len, text); | 1247 | utf8to16 (utf8_text, utf8_len, text); |
| 1248 | } | 1248 | } |
| 1249 | else | 1249 | else |
| @@ -1386,8 +1386,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 1386 | 1386 | ||
| 1387 | if (wv->key != NULL) | 1387 | if (wv->key != NULL) |
| 1388 | { | 1388 | { |
| 1389 | SAFE_ALLOCA (out_string, char *, | 1389 | out_string = SAFE_ALLOCA (strlen (wv->name) + strlen (wv->key) + 2); |
| 1390 | strlen (wv->name) + strlen (wv->key) + 2); | ||
| 1391 | strcpy (out_string, wv->name); | 1390 | strcpy (out_string, wv->name); |
| 1392 | strcat (out_string, "\t"); | 1391 | strcat (out_string, "\t"); |
| 1393 | strcat (out_string, wv->key); | 1392 | strcat (out_string, wv->key); |
| @@ -1421,7 +1420,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 1421 | if (nlen > orig_len) | 1420 | if (nlen > orig_len) |
| 1422 | { | 1421 | { |
| 1423 | p = out_string; | 1422 | p = out_string; |
| 1424 | SAFE_ALLOCA (out_string, char *, nlen + 1); | 1423 | out_string = SAFE_ALLOCA (nlen + 1); |
| 1425 | q = out_string; | 1424 | q = out_string; |
| 1426 | while (*p) | 1425 | while (*p) |
| 1427 | { | 1426 | { |
| @@ -1481,7 +1480,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 1481 | if (fuFlags & MF_OWNERDRAW) | 1480 | if (fuFlags & MF_OWNERDRAW) |
| 1482 | utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR)); | 1481 | utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR)); |
| 1483 | else | 1482 | else |
| 1484 | SAFE_ALLOCA (utf16_string, WCHAR *, (utf8_len + 1) * sizeof (WCHAR)); | 1483 | utf16_string = SAFE_ALLOCA ((utf8_len + 1) * sizeof (WCHAR)); |
| 1485 | 1484 | ||
| 1486 | utf8to16 (out_string, utf8_len, utf16_string); | 1485 | utf8to16 (out_string, utf8_len, utf16_string); |
| 1487 | return_value = unicode_append_menu (menu, fuFlags, | 1486 | return_value = unicode_append_menu (menu, fuFlags, |
diff --git a/src/xdisp.c b/src/xdisp.c index 3e14b06357c..2af15acbe65 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -2660,9 +2660,9 @@ init_iterator (struct it *it, struct window *w, | |||
| 2660 | is invisible. >0 means lines indented more than this value are | 2660 | is invisible. >0 means lines indented more than this value are |
| 2661 | invisible. */ | 2661 | invisible. */ |
| 2662 | it->selective = (INTEGERP (BVAR (current_buffer, selective_display)) | 2662 | it->selective = (INTEGERP (BVAR (current_buffer, selective_display)) |
| 2663 | ? clip_to_bounds | 2663 | ? (clip_to_bounds |
| 2664 | (-1, XINT (BVAR (current_buffer, selective_display)), | 2664 | (-1, XINT (BVAR (current_buffer, selective_display)), |
| 2665 | PTRDIFF_MAX) | 2665 | PTRDIFF_MAX)) |
| 2666 | : (!NILP (BVAR (current_buffer, selective_display)) | 2666 | : (!NILP (BVAR (current_buffer, selective_display)) |
| 2667 | ? -1 : 0)); | 2667 | ? -1 : 0)); |
| 2668 | it->selective_display_ellipsis_p | 2668 | it->selective_display_ellipsis_p |
| @@ -9268,7 +9268,7 @@ add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2) | |||
| 9268 | msg = Fformat (3, args); | 9268 | msg = Fformat (3, args); |
| 9269 | 9269 | ||
| 9270 | len = SBYTES (msg) + 1; | 9270 | len = SBYTES (msg) + 1; |
| 9271 | SAFE_ALLOCA (buffer, char *, len); | 9271 | buffer = SAFE_ALLOCA (len); |
| 9272 | memcpy (buffer, SDATA (msg), len); | 9272 | memcpy (buffer, SDATA (msg), len); |
| 9273 | 9273 | ||
| 9274 | message_dolog (buffer, len - 1, 1, 0); | 9274 | message_dolog (buffer, len - 1, 1, 0); |
| @@ -9595,10 +9595,8 @@ message3 (Lisp_Object m, ptrdiff_t nbytes, int multibyte) | |||
| 9595 | message_log_maybe_newline (); | 9595 | message_log_maybe_newline (); |
| 9596 | if (STRINGP (m)) | 9596 | if (STRINGP (m)) |
| 9597 | { | 9597 | { |
| 9598 | char *buffer; | ||
| 9599 | USE_SAFE_ALLOCA; | 9598 | USE_SAFE_ALLOCA; |
| 9600 | 9599 | char *buffer = SAFE_ALLOCA (nbytes); | |
| 9601 | SAFE_ALLOCA (buffer, char *, nbytes); | ||
| 9602 | memcpy (buffer, SDATA (m), nbytes); | 9600 | memcpy (buffer, SDATA (m), nbytes); |
| 9603 | message_dolog (buffer, nbytes, 1, multibyte); | 9601 | message_dolog (buffer, nbytes, 1, multibyte); |
| 9604 | SAFE_FREE (); | 9602 | SAFE_FREE (); |
| @@ -11173,7 +11171,7 @@ prepare_menu_bars (void) | |||
| 11173 | #ifdef HAVE_NS | 11171 | #ifdef HAVE_NS |
| 11174 | if (windows_or_buffers_changed | 11172 | if (windows_or_buffers_changed |
| 11175 | && FRAME_NS_P (f)) | 11173 | && FRAME_NS_P (f)) |
| 11176 | ns_set_doc_edited | 11174 | ns_set_doc_edited |
| 11177 | (f, Fbuffer_modified_p | 11175 | (f, Fbuffer_modified_p |
| 11178 | (WVAR (XWINDOW (FVAR (f, selected_window)), buffer))); | 11176 | (WVAR (XWINDOW (FVAR (f, selected_window)), buffer))); |
| 11179 | #endif | 11177 | #endif |
| @@ -11478,8 +11476,9 @@ update_tool_bar (struct frame *f, int save_match_data) | |||
| 11478 | selected_frame = frame; | 11476 | selected_frame = frame; |
| 11479 | 11477 | ||
| 11480 | /* Build desired tool-bar items from keymaps. */ | 11478 | /* Build desired tool-bar items from keymaps. */ |
| 11481 | new_tool_bar = tool_bar_items | 11479 | new_tool_bar |
| 11482 | (Fcopy_sequence (FVAR (f, tool_bar_items)), &new_n_tool_bar); | 11480 | = tool_bar_items (Fcopy_sequence (FVAR (f, tool_bar_items)), |
| 11481 | &new_n_tool_bar); | ||
| 11483 | 11482 | ||
| 11484 | /* Redisplay the tool-bar if we changed it. */ | 11483 | /* Redisplay the tool-bar if we changed it. */ |
| 11485 | if (new_n_tool_bar != f->n_tool_bar_items | 11484 | if (new_n_tool_bar != f->n_tool_bar_items |
| @@ -24956,7 +24955,7 @@ x_produce_glyphs (struct it *it) | |||
| 24956 | font_descent = FONT_DESCENT (font) - boff; | 24955 | font_descent = FONT_DESCENT (font) - boff; |
| 24957 | font_height = FONT_HEIGHT (font); | 24956 | font_height = FONT_HEIGHT (font); |
| 24958 | 24957 | ||
| 24959 | cmp->font = (void *) font; | 24958 | cmp->font = font; |
| 24960 | 24959 | ||
| 24961 | pcm = NULL; | 24960 | pcm = NULL; |
| 24962 | if (! font_not_found_p) | 24961 | if (! font_not_found_p) |
diff --git a/src/xfaces.c b/src/xfaces.c index 9d264253115..df6cf6a3684 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -1559,8 +1559,10 @@ static enum font_property_index font_props_for_sorting[FONT_SIZE_INDEX]; | |||
| 1559 | static int | 1559 | static int |
| 1560 | compare_fonts_by_sort_order (const void *v1, const void *v2) | 1560 | compare_fonts_by_sort_order (const void *v1, const void *v2) |
| 1561 | { | 1561 | { |
| 1562 | Lisp_Object font1 = *(Lisp_Object *) v1; | 1562 | Lisp_Object const *p1 = v1; |
| 1563 | Lisp_Object font2 = *(Lisp_Object *) v2; | 1563 | Lisp_Object const *p2 = v2; |
| 1564 | Lisp_Object font1 = *p1; | ||
| 1565 | Lisp_Object font2 = *p2; | ||
| 1564 | int i; | 1566 | int i; |
| 1565 | 1567 | ||
| 1566 | for (i = 0; i < FONT_SIZE_INDEX; i++) | 1568 | for (i = 0; i < FONT_SIZE_INDEX; i++) |
diff --git a/src/xfns.c b/src/xfns.c index df66cbe1ab4..5e92fe9b187 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -460,7 +460,7 @@ x_real_positions (FRAME_PTR f, int *xptr, int *yptr) | |||
| 460 | if (! success) | 460 | if (! success) |
| 461 | break; | 461 | break; |
| 462 | 462 | ||
| 463 | XFree ((char *) tmp_children); | 463 | XFree (tmp_children); |
| 464 | 464 | ||
| 465 | if (wm_window == rootw || had_errors) | 465 | if (wm_window == rootw || had_errors) |
| 466 | break; | 466 | break; |
| @@ -4001,7 +4001,7 @@ select_visual (struct x_display_info *dpyinfo) | |||
| 4001 | fatal ("Can't get proper X visual info"); | 4001 | fatal ("Can't get proper X visual info"); |
| 4002 | 4002 | ||
| 4003 | dpyinfo->n_planes = vinfo->depth; | 4003 | dpyinfo->n_planes = vinfo->depth; |
| 4004 | XFree ((char *) vinfo); | 4004 | XFree (vinfo); |
| 4005 | } | 4005 | } |
| 4006 | } | 4006 | } |
| 4007 | 4007 | ||
diff --git a/src/xfont.c b/src/xfont.c index 736c1161e27..1ebac6100f2 100644 --- a/src/xfont.c +++ b/src/xfont.c | |||
| @@ -1035,10 +1035,8 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_bac | |||
| 1035 | 1035 | ||
| 1036 | if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) | 1036 | if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) |
| 1037 | { | 1037 | { |
| 1038 | char *str; | ||
| 1039 | USE_SAFE_ALLOCA; | 1038 | USE_SAFE_ALLOCA; |
| 1040 | 1039 | char *str = SAFE_ALLOCA (len); | |
| 1041 | SAFE_ALLOCA (str, char *, len); | ||
| 1042 | for (i = 0; i < len ; i++) | 1040 | for (i = 0; i < len ; i++) |
| 1043 | str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); | 1041 | str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); |
| 1044 | BLOCK_INPUT; | 1042 | BLOCK_INPUT; |
diff --git a/src/xselect.c b/src/xselect.c index e2da561e953..ff779b91944 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -216,7 +216,7 @@ x_stop_queuing_selection_requests (void) | |||
| 216 | TRACE1 ("RESTORE SELECTION EVENT %p", queue_tmp); | 216 | TRACE1 ("RESTORE SELECTION EVENT %p", queue_tmp); |
| 217 | kbd_buffer_unget_event (&queue_tmp->event); | 217 | kbd_buffer_unget_event (&queue_tmp->event); |
| 218 | selection_queue = queue_tmp->next; | 218 | selection_queue = queue_tmp->next; |
| 219 | xfree ((char *)queue_tmp); | 219 | xfree (queue_tmp); |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | 222 | ||
| @@ -1321,7 +1321,7 @@ x_get_window_property (Display *display, Window window, Atom property, | |||
| 1321 | goto done; | 1321 | goto done; |
| 1322 | 1322 | ||
| 1323 | /* This was allocated by Xlib, so use XFree. */ | 1323 | /* This was allocated by Xlib, so use XFree. */ |
| 1324 | XFree ((char *) tmp_data); | 1324 | XFree (tmp_data); |
| 1325 | 1325 | ||
| 1326 | if (*actual_type_ret == None || *actual_format_ret == 0) | 1326 | if (*actual_type_ret == None || *actual_format_ret == 0) |
| 1327 | goto done; | 1327 | goto done; |
| @@ -1403,7 +1403,7 @@ x_get_window_property (Display *display, Window window, Atom property, | |||
| 1403 | offset += bytes_gotten; | 1403 | offset += bytes_gotten; |
| 1404 | 1404 | ||
| 1405 | /* This was allocated by Xlib, so use XFree. */ | 1405 | /* This was allocated by Xlib, so use XFree. */ |
| 1406 | XFree ((char *) tmp_data); | 1406 | XFree (tmp_data); |
| 1407 | } | 1407 | } |
| 1408 | 1408 | ||
| 1409 | XFlush (display); | 1409 | XFlush (display); |
| @@ -1568,7 +1568,7 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1568 | BLOCK_INPUT; | 1568 | BLOCK_INPUT; |
| 1569 | /* Use xfree, not XFree, because x_get_window_property | 1569 | /* Use xfree, not XFree, because x_get_window_property |
| 1570 | calls xmalloc itself. */ | 1570 | calls xmalloc itself. */ |
| 1571 | xfree ((char *) data); | 1571 | xfree (data); |
| 1572 | UNBLOCK_INPUT; | 1572 | UNBLOCK_INPUT; |
| 1573 | receive_incremental_selection (display, window, property, target_type, | 1573 | receive_incremental_selection (display, window, property, target_type, |
| 1574 | min_size_bytes, &data, &bytes, | 1574 | min_size_bytes, &data, &bytes, |
| @@ -1589,7 +1589,7 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1589 | 1589 | ||
| 1590 | /* Use xfree, not XFree, because x_get_window_property | 1590 | /* Use xfree, not XFree, because x_get_window_property |
| 1591 | calls xmalloc itself. */ | 1591 | calls xmalloc itself. */ |
| 1592 | xfree ((char *) data); | 1592 | xfree (data); |
| 1593 | return val; | 1593 | return val; |
| 1594 | } | 1594 | } |
| 1595 | 1595 | ||
diff --git a/src/xterm.c b/src/xterm.c index 6831ef6971e..ac846f23e95 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -520,7 +520,7 @@ x_set_frame_alpha (struct frame *f) | |||
| 520 | if (rc == Success && actual != None) | 520 | if (rc == Success && actual != None) |
| 521 | { | 521 | { |
| 522 | unsigned long value = *(unsigned long *)data; | 522 | unsigned long value = *(unsigned long *)data; |
| 523 | XFree ((void *) data); | 523 | XFree (data); |
| 524 | if (value == opac) | 524 | if (value == opac) |
| 525 | { | 525 | { |
| 526 | x_uncatch_errors (); | 526 | x_uncatch_errors (); |
| @@ -3710,7 +3710,7 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo) | |||
| 3710 | dpyinfo->alt_mod_mask &= ~dpyinfo->meta_mod_mask; | 3710 | dpyinfo->alt_mod_mask &= ~dpyinfo->meta_mod_mask; |
| 3711 | } | 3711 | } |
| 3712 | 3712 | ||
| 3713 | XFree ((char *) syms); | 3713 | XFree (syms); |
| 3714 | XFreeModifiermap (mods); | 3714 | XFreeModifiermap (mods); |
| 3715 | } | 3715 | } |
| 3716 | 3716 | ||