aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.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/process.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/process.c')
-rw-r--r--src/process.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/process.c b/src/process.c
index 3f329872c76..2cb9e8de15f 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1365,7 +1365,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1365 val = Vcoding_system_for_read; 1365 val = Vcoding_system_for_read;
1366 if (NILP (val)) 1366 if (NILP (val))
1367 { 1367 {
1368 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); 1368 args2 = alloca ((nargs + 1) * sizeof *args2);
1369 args2[0] = Qstart_process; 1369 args2[0] = Qstart_process;
1370 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; 1370 for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
1371 GCPRO2 (proc, current_dir); 1371 GCPRO2 (proc, current_dir);
@@ -1384,7 +1384,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1384 { 1384 {
1385 if (EQ (coding_systems, Qt)) 1385 if (EQ (coding_systems, Qt))
1386 { 1386 {
1387 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); 1387 args2 = alloca ((nargs + 1) * sizeof *args2);
1388 args2[0] = Qstart_process; 1388 args2[0] = Qstart_process;
1389 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; 1389 for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
1390 GCPRO2 (proc, current_dir); 1390 GCPRO2 (proc, current_dir);
@@ -1478,7 +1478,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1478 1478
1479 /* Now that everything is encoded we can collect the strings into 1479 /* Now that everything is encoded we can collect the strings into
1480 NEW_ARGV. */ 1480 NEW_ARGV. */
1481 new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); 1481 new_argv = alloca ((nargs - 1) * sizeof *new_argv);
1482 new_argv[nargs - 2] = 0; 1482 new_argv[nargs - 2] = 0;
1483 1483
1484 for (i = nargs - 2; i-- != 0; ) 1484 for (i = nargs - 2; i-- != 0; )
@@ -5037,7 +5037,7 @@ read_process_output (Lisp_Object proc, register int channel)
5037 ptrdiff_t count = SPECPDL_INDEX (); 5037 ptrdiff_t count = SPECPDL_INDEX ();
5038 Lisp_Object odeactivate; 5038 Lisp_Object odeactivate;
5039 5039
5040 chars = (char *) alloca (carryover + readmax); 5040 chars = alloca (carryover + readmax);
5041 if (carryover) 5041 if (carryover)
5042 /* See the comment above. */ 5042 /* See the comment above. */
5043 memcpy (chars, SDATA (p->decoding_buf), carryover); 5043 memcpy (chars, SDATA (p->decoding_buf), carryover);
@@ -7083,8 +7083,7 @@ setup_process_coding_systems (Lisp_Object process)
7083 return; 7083 return;
7084 7084
7085 if (!proc_decode_coding_system[inch]) 7085 if (!proc_decode_coding_system[inch])
7086 proc_decode_coding_system[inch] 7086 proc_decode_coding_system[inch] = xmalloc (sizeof (struct coding_system));
7087 = xmalloc (sizeof (struct coding_system));
7088 coding_system = p->decode_coding_system; 7087 coding_system = p->decode_coding_system;
7089 if (! NILP (p->filter)) 7088 if (! NILP (p->filter))
7090 ; 7089 ;
@@ -7096,8 +7095,7 @@ setup_process_coding_systems (Lisp_Object process)
7096 setup_coding_system (coding_system, proc_decode_coding_system[inch]); 7095 setup_coding_system (coding_system, proc_decode_coding_system[inch]);
7097 7096
7098 if (!proc_encode_coding_system[outch]) 7097 if (!proc_encode_coding_system[outch])
7099 proc_encode_coding_system[outch] 7098 proc_encode_coding_system[outch] = xmalloc (sizeof (struct coding_system));
7100 = xmalloc (sizeof (struct coding_system));
7101 setup_coding_system (p->encode_coding_system, 7099 setup_coding_system (p->encode_coding_system,
7102 proc_encode_coding_system[outch]); 7100 proc_encode_coding_system[outch]);
7103#endif 7101#endif