aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.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/doc.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/doc.c')
-rw-r--r--src/doc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/doc.c b/src/doc.c
index 54d028ab61c..6b356d57cb3 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -577,14 +577,13 @@ the same file name is found in the `doc-directory'. */)
577 (0) 577 (0)
578#endif /* CANNOT_DUMP */ 578#endif /* CANNOT_DUMP */
579 { 579 {
580 name = (char *) alloca (SCHARS (filename) + 14); 580 name = alloca (SCHARS (filename) + 14);
581 strcpy (name, "../etc/"); 581 strcpy (name, "../etc/");
582 } 582 }
583 else 583 else
584 { 584 {
585 CHECK_STRING (Vdoc_directory); 585 CHECK_STRING (Vdoc_directory);
586 name = (char *) alloca (SCHARS (filename) 586 name = alloca (SCHARS (filename) + SCHARS (Vdoc_directory) + 1);
587 + SCHARS (Vdoc_directory) + 1);
588 strcpy (name, SSDATA (Vdoc_directory)); 587 strcpy (name, SSDATA (Vdoc_directory));
589 } 588 }
590 strcat (name, SSDATA (filename)); /*** Add this line ***/ 589 strcat (name, SSDATA (filename)); /*** Add this line ***/
@@ -828,7 +827,7 @@ Otherwise, return a new string, without any text properties. */)
828 ptrdiff_t offset = bufp - buf; 827 ptrdiff_t offset = bufp - buf;
829 if (STRING_BYTES_BOUND - 4 < bsize) 828 if (STRING_BYTES_BOUND - 4 < bsize)
830 string_overflow (); 829 string_overflow ();
831 buf = (char *) xrealloc (buf, bsize += 4); 830 buf = xrealloc (buf, bsize += 4);
832 bufp = buf + offset; 831 bufp = buf + offset;
833 memcpy (bufp, "M-x ", 4); 832 memcpy (bufp, "M-x ", 4);
834 bufp += 4; 833 bufp += 4;
@@ -924,7 +923,7 @@ Otherwise, return a new string, without any text properties. */)
924 ptrdiff_t offset = bufp - buf; 923 ptrdiff_t offset = bufp - buf;
925 if (STRING_BYTES_BOUND - length_byte < bsize) 924 if (STRING_BYTES_BOUND - length_byte < bsize)
926 string_overflow (); 925 string_overflow ();
927 buf = (char *) xrealloc (buf, bsize += length_byte); 926 buf = xrealloc (buf, bsize += length_byte);
928 bufp = buf + offset; 927 bufp = buf + offset;
929 memcpy (bufp, start, length_byte); 928 memcpy (bufp, start, length_byte);
930 bufp += length_byte; 929 bufp += length_byte;