Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
5780:580ebed3500a | 5781:0853e1ec8529 |
---|---|
1801 */ | 1801 */ |
1802 (filename, newname, ok_if_already_exists, keep_time)) | 1802 (filename, newname, ok_if_already_exists, keep_time)) |
1803 { | 1803 { |
1804 /* This function can call Lisp. GC checked 2000-07-28 ben */ | 1804 /* This function can call Lisp. GC checked 2000-07-28 ben */ |
1805 int ifd, ofd, n; | 1805 int ifd, ofd, n; |
1806 Rawbyte buf[READ_BUF_SIZE]; | 1806 Rawbyte *buf = alloca_rawbytes (READ_BUF_SIZE); |
1807 struct stat st, out_st; | 1807 struct stat st, out_st; |
1808 Lisp_Object handler; | 1808 Lisp_Object handler; |
1809 int speccount = specpdl_depth (); | 1809 int speccount = specpdl_depth (); |
1810 struct gcpro gcpro1, gcpro2; | 1810 struct gcpro gcpro1, gcpro2; |
1811 /* Lisp_Object args[6]; */ | 1811 /* Lisp_Object args[6]; */ |
1907 { | 1907 { |
1908 Lisp_Object ofd_locative = noseeum_cons (make_fixnum (ofd), Qnil); | 1908 Lisp_Object ofd_locative = noseeum_cons (make_fixnum (ofd), Qnil); |
1909 | 1909 |
1910 record_unwind_protect (close_file_unwind, ofd_locative); | 1910 record_unwind_protect (close_file_unwind, ofd_locative); |
1911 | 1911 |
1912 while ((n = read_allowing_quit (ifd, buf, sizeof (buf))) > 0) | 1912 while ((n = read_allowing_quit (ifd, buf, READ_BUF_SIZE)) > 0) |
1913 { | 1913 { |
1914 if (write_allowing_quit (ofd, buf, n) != n) | 1914 if (write_allowing_quit (ofd, buf, n) != n) |
1915 report_file_error ("I/O error", newname); | 1915 report_file_error ("I/O error", newname); |
1916 } | 1916 } |
1917 | 1917 |
2897 Charcount inserted = 0; | 2897 Charcount inserted = 0; |
2898 int speccount; | 2898 int speccount; |
2899 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 2899 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
2900 Lisp_Object val; | 2900 Lisp_Object val; |
2901 int total; | 2901 int total; |
2902 Ibyte read_buf[READ_BUF_SIZE]; | 2902 Ibyte *read_buf = alloca_ibytes (READ_BUF_SIZE); |
2903 int mc_count; | 2903 int mc_count; |
2904 struct buffer *buf = current_buffer; | 2904 struct buffer *buf = current_buffer; |
2905 Lisp_Object curbuf; | 2905 Lisp_Object curbuf; |
2906 int not_regular = 0; | 2906 int not_regular = 0; |
2907 int do_speedy_insert = | 2907 int do_speedy_insert = |
3197 { | 3197 { |
3198 Bytecount this_len; | 3198 Bytecount this_len; |
3199 Charcount cc_inserted, this_tell = last_tell; | 3199 Charcount cc_inserted, this_tell = last_tell; |
3200 | 3200 |
3201 QUIT; | 3201 QUIT; |
3202 this_len = Lstream_read (XLSTREAM (stream), read_buf, | 3202 this_len = Lstream_read (XLSTREAM (stream), read_buf, READ_BUF_SIZE); |
3203 sizeof (read_buf)); | |
3204 | 3203 |
3205 if (this_len <= 0) | 3204 if (this_len <= 0) |
3206 { | 3205 { |
3207 if (this_len < 0) | 3206 if (this_len < 0) |
3208 saverrno = errno; | 3207 saverrno = errno; |