=== modified file 'src/fileio.c' --- src/fileio.c 2014-09-02 11:41:22 +0000 +++ src/fileio.c 2014-09-02 11:47:45 +0000 @@ -1179,11 +1179,11 @@ char newdir_utf8[MAX_UTF8_PATH]; filename_from_ansi (newdir, newdir_utf8); - tem = build_string (newdir_utf8); + tem = alloca_string (newdir_utf8); } else #endif - tem = build_string (newdir); + tem = alloca_string (newdir); newdirlen = SBYTES (tem); if (multibyte && !STRING_MULTIBYTE (tem)) { @@ -1215,7 +1215,7 @@ /* `getpwnam' may return a unibyte string, which will bite us since we expect the directory to be multibyte. */ - tem = build_string (newdir); + tem = alloca_string (newdir); newdirlen = SBYTES (tem); if (multibyte && !STRING_MULTIBYTE (tem)) { @@ -1249,7 +1249,7 @@ adir = NULL; else if (multibyte) { - Lisp_Object tem = build_string (adir); + Lisp_Object tem = alloca_string (adir); tem = DECODE_FILE (tem); newdirlen = SBYTES (tem); @@ -1350,7 +1350,7 @@ getcwd (adir, adir_size); if (multibyte) { - Lisp_Object tem = build_string (adir); + Lisp_Object tem = alloca_string (adir); tem = DECODE_FILE (tem); newdirlen = SBYTES (tem); === modified file 'src/lisp.h' --- src/lisp.h 2014-09-02 06:49:40 +0000 +++ src/lisp.h 2014-09-02 12:31:01 +0000 @@ -4459,6 +4459,25 @@ memcpy (alloca (SBYTES (string) + 1), \ SSDATA (string), SBYTES (string) + 1) +/* Create temporary Lisp_String. Use alloca and do not disturb GC. */ + +#define alloca_string(str) \ + ({ Lisp_Object string; \ + struct Lisp_String *s; \ + ptrdiff_t nchars, nbytes, size = strlen (str); \ + parse_str_as_multibyte ((const unsigned char *) str, \ + size, &nchars, &nbytes); \ + s = alloca (sizeof *s + nbytes + 1); \ + s->data = (unsigned char *) s + sizeof (*s); \ + memcpy (s->data, str, nbytes); \ + s->data[size] = '\0'; \ + s->intervals = NULL; \ + if (nbytes == nchars || nbytes != size) \ + s->size = size, s->size_byte = -1; \ + else \ + s->size = nchars, s->size_byte = nbytes; \ + XSETSTRING (string, s); string; }) + /* Set up the name of the machine we're running on. */ extern void init_system_name (void);