aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2012-07-05 11:35:48 -0700
committerPaul Eggert2012-07-05 11:35:48 -0700
commit38182d901d030c7d65f4aa7a49b583afb30eb9b7 (patch)
treea69e1a571495d6ca1c034359d7c995639774ab9b /src/coding.c
parent6dd5a677dbf794eedaa8325c46d57ac041373361 (diff)
downloademacs-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/coding.c')
-rw-r--r--src/coding.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/coding.c b/src/coding.c
index 891fea09abf..4b2a9740121 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1145,8 +1145,8 @@ coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes)
1145{ 1145{
1146 if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) 1146 if (STRING_BYTES_BOUND - coding->dst_bytes < bytes)
1147 string_overflow (); 1147 string_overflow ();
1148 coding->destination = (unsigned char *) xrealloc (coding->destination, 1148 coding->destination = xrealloc (coding->destination,
1149 coding->dst_bytes + bytes); 1149 coding->dst_bytes + bytes);
1150 coding->dst_bytes += bytes; 1150 coding->dst_bytes += bytes;
1151} 1151}
1152 1152
@@ -7010,7 +7010,7 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
7010 coding->charbuf = NULL; \ 7010 coding->charbuf = NULL; \
7011 while (size > 1024) \ 7011 while (size > 1024) \
7012 { \ 7012 { \
7013 coding->charbuf = (int *) alloca (sizeof (int) * size); \ 7013 coding->charbuf = alloca (sizeof (int) * size); \
7014 if (coding->charbuf) \ 7014 if (coding->charbuf) \
7015 break; \ 7015 break; \
7016 size >>= 1; \ 7016 size >>= 1; \
@@ -9568,7 +9568,7 @@ make_subsidiaries (Lisp_Object base)
9568{ 9568{
9569 Lisp_Object subsidiaries; 9569 Lisp_Object subsidiaries;
9570 ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base)); 9570 ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base));
9571 char *buf = (char *) alloca (base_name_len + 6); 9571 char *buf = alloca (base_name_len + 6);
9572 int i; 9572 int i;
9573 9573
9574 memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); 9574 memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len);