diff src/fileio.c @ 5781:0853e1ec8529

Use alloca_{rawbytes,ibytes} in #'copy-file, #'insert-file-contents-internal src/ChangeLog addition: 2014-01-20 Aidan Kehoe <kehoea@parhasard.net> * fileio.c (Fcopy_file, Finsert_file_contents_internal): Use alloca_{rawbytes,ibytes} here instead of the implicit alloca on the stack; doesn't change where the buffers are allocated for these two functions, but does mean that decisions about alloca vs. malloc based on buffer size are made in the same place (ultimately, the ALLOCA() macro).
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 20 Jan 2014 17:53:07 +0000
parents e9d0228c5671
children 7277cf461612
line wrap: on
line diff
--- a/src/fileio.c	Sat Jan 18 17:40:41 2014 +0100
+++ b/src/fileio.c	Mon Jan 20 17:53:07 2014 +0000
@@ -1803,7 +1803,7 @@
 {
   /* This function can call Lisp.  GC checked 2000-07-28 ben */
   int ifd, ofd, n;
-  Rawbyte buf[READ_BUF_SIZE];
+  Rawbyte *buf = alloca_rawbytes (READ_BUF_SIZE);
   struct stat st, out_st;
   Lisp_Object handler;
   int speccount = specpdl_depth ();
@@ -1909,7 +1909,7 @@
 
     record_unwind_protect (close_file_unwind, ofd_locative);
 
-    while ((n = read_allowing_quit (ifd, buf, sizeof (buf))) > 0)
+    while ((n = read_allowing_quit (ifd, buf, READ_BUF_SIZE)) > 0)
     {
       if (write_allowing_quit (ofd, buf, n) != n)
 	report_file_error ("I/O error", newname);
@@ -2899,7 +2899,7 @@
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   Lisp_Object val;
   int total;
-  Ibyte read_buf[READ_BUF_SIZE];
+  Ibyte *read_buf = alloca_ibytes (READ_BUF_SIZE);
   int mc_count;
   struct buffer *buf = current_buffer;
   Lisp_Object curbuf;
@@ -3199,8 +3199,7 @@
 	Charcount cc_inserted, this_tell = last_tell;
 
 	QUIT;
-	this_len = Lstream_read (XLSTREAM (stream), read_buf,
-				 sizeof (read_buf));
+	this_len = Lstream_read (XLSTREAM (stream), read_buf, READ_BUF_SIZE);
 
 	if (this_len <= 0)
 	  {