diff options
| author | Paul Eggert | 2012-07-05 11:35:48 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-05 11:35:48 -0700 |
| commit | 38182d901d030c7d65f4aa7a49b583afb30eb9b7 (patch) | |
| tree | a69e1a571495d6ca1c034359d7c995639774ab9b /src/lread.c | |
| parent | 6dd5a677dbf794eedaa8325c46d57ac041373361 (diff) | |
| download | emacs-38182d901d030c7d65f4aa7a49b583afb30eb9b7.tar.gz emacs-38182d901d030c7d65f4aa7a49b583afb30eb9b7.zip | |
More xmalloc and related cleanup.
* alloc.c, bidi.c, buffer.c, buffer.h, bytecode.c, callint.c:
* callproc.c, charset.c, coding.c, composite.c, data.c, dispnew.c:
* doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, fns.c:
* font.c, fontset.c, frame.c, fringe.c, ftfont.c, ftxfont.c, gmalloc.c:
* gtkutil.c, image.c, keyboard.c, keymap.c, lread.c, macros.c, menu.c:
* nsfns.m, nsfont.m, nsmenu.m, nsterm.m, print.c, process.c, ralloc.c:
* regex.c, region-cache.c, scroll.c, search.c, sound.c, syntax.c:
* sysdep.c, term.c, termcap.c, unexmacosx.c, window.c, xdisp.c:
* xfaces.c, xfns.c, xftfont.c, xgselect.c, xmenu.c, xrdb.c, xselect.c:
* xterm.c:
Omit needless casts involving void * pointers and allocation.
Prefer "P = xmalloc (sizeof *P)" to "P = xmalloc (sizeof (TYPE_OF_P))",
as the former is more robust if P's type is changed.
Prefer xzalloc to xmalloc + memset 0.
Simplify malloc-or-realloc to realloc.
Don't worry about xmalloc returning a null pointer.
Prefer xstrdup to xmalloc + strcpy.
* editfns.c (Fmessage_box): Grow message_text by at least 80 when
growing it.
* keyboard.c (apply_modifiers_uncached): Prefer local array to
alloca of a constant.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lread.c b/src/lread.c index 670831081e8..19783d3102b 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1479,7 +1479,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1479 | this path element/specified file name and any possible suffix. */ | 1479 | this path element/specified file name and any possible suffix. */ |
| 1480 | want_length = max_suffix_len + SBYTES (filename); | 1480 | want_length = max_suffix_len + SBYTES (filename); |
| 1481 | if (fn_size <= want_length) | 1481 | if (fn_size <= want_length) |
| 1482 | fn = (char *) alloca (fn_size = 100 + want_length); | 1482 | fn = alloca (fn_size = 100 + want_length); |
| 1483 | 1483 | ||
| 1484 | /* Loop over suffixes. */ | 1484 | /* Loop over suffixes. */ |
| 1485 | for (tail = NILP (suffixes) ? Fcons (empty_unibyte_string, Qnil) : suffixes; | 1485 | for (tail = NILP (suffixes) ? Fcons (empty_unibyte_string, Qnil) : suffixes; |
| @@ -2630,8 +2630,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2630 | } | 2630 | } |
| 2631 | if (nskip > saved_doc_string_size) | 2631 | if (nskip > saved_doc_string_size) |
| 2632 | { | 2632 | { |
| 2633 | saved_doc_string = (char *) xrealloc (saved_doc_string, | 2633 | saved_doc_string = xrealloc (saved_doc_string, nskip + extra); |
| 2634 | nskip + extra); | ||
| 2635 | saved_doc_string_size = nskip + extra; | 2634 | saved_doc_string_size = nskip + extra; |
| 2636 | } | 2635 | } |
| 2637 | 2636 | ||
| @@ -2894,8 +2893,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2894 | ptrdiff_t offset = p - read_buffer; | 2893 | ptrdiff_t offset = p - read_buffer; |
| 2895 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 2894 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 2896 | memory_full (SIZE_MAX); | 2895 | memory_full (SIZE_MAX); |
| 2897 | read_buffer = (char *) xrealloc (read_buffer, | 2896 | read_buffer = xrealloc (read_buffer, read_buffer_size * 2); |
| 2898 | read_buffer_size * 2); | ||
| 2899 | read_buffer_size *= 2; | 2897 | read_buffer_size *= 2; |
| 2900 | p = read_buffer + offset; | 2898 | p = read_buffer + offset; |
| 2901 | end = read_buffer + read_buffer_size; | 2899 | end = read_buffer + read_buffer_size; |
| @@ -3029,8 +3027,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3029 | ptrdiff_t offset = p - read_buffer; | 3027 | ptrdiff_t offset = p - read_buffer; |
| 3030 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 3028 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 3031 | memory_full (SIZE_MAX); | 3029 | memory_full (SIZE_MAX); |
| 3032 | read_buffer = (char *) xrealloc (read_buffer, | 3030 | read_buffer = xrealloc (read_buffer, read_buffer_size * 2); |
| 3033 | read_buffer_size * 2); | ||
| 3034 | read_buffer_size *= 2; | 3031 | read_buffer_size *= 2; |
| 3035 | p = read_buffer + offset; | 3032 | p = read_buffer + offset; |
| 3036 | end = read_buffer + read_buffer_size; | 3033 | end = read_buffer + read_buffer_size; |
| @@ -3060,8 +3057,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3060 | ptrdiff_t offset = p - read_buffer; | 3057 | ptrdiff_t offset = p - read_buffer; |
| 3061 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) | 3058 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size) |
| 3062 | memory_full (SIZE_MAX); | 3059 | memory_full (SIZE_MAX); |
| 3063 | read_buffer = (char *) xrealloc (read_buffer, | 3060 | read_buffer = xrealloc (read_buffer, read_buffer_size * 2); |
| 3064 | read_buffer_size * 2); | ||
| 3065 | read_buffer_size *= 2; | 3061 | read_buffer_size *= 2; |
| 3066 | p = read_buffer + offset; | 3062 | p = read_buffer + offset; |
| 3067 | end = read_buffer + read_buffer_size; | 3063 | end = read_buffer + read_buffer_size; |