diff options
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/data.c b/src/data.c index 935c4348bb7..1071107947c 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -1983,11 +1983,6 @@ or a byte-code object. IDX starts at 0. */) | |||
| 1983 | } | 1983 | } |
| 1984 | } | 1984 | } |
| 1985 | 1985 | ||
| 1986 | /* Don't use alloca for relocating string data larger than this, lest | ||
| 1987 | we overflow their stack. The value is the same as what used in | ||
| 1988 | fns.c for base64 handling. */ | ||
| 1989 | #define MAX_ALLOCA 16*1024 | ||
| 1990 | |||
| 1991 | DEFUN ("aset", Faset, Saset, 3, 3, 0, | 1986 | DEFUN ("aset", Faset, Saset, 3, 3, 0, |
| 1992 | doc: /* Store into the element of ARRAY at index IDX the value NEWELT. | 1987 | doc: /* Store into the element of ARRAY at index IDX the value NEWELT. |
| 1993 | Return NEWELT. ARRAY may be a vector, a string, a char-table or a | 1988 | Return NEWELT. ARRAY may be a vector, a string, a char-table or a |
| @@ -2051,10 +2046,9 @@ bool-vector. IDX starts at 0. */) | |||
| 2051 | /* We must relocate the string data. */ | 2046 | /* We must relocate the string data. */ |
| 2052 | int nchars = SCHARS (array); | 2047 | int nchars = SCHARS (array); |
| 2053 | unsigned char *str; | 2048 | unsigned char *str; |
| 2049 | USE_SAFE_ALLOCA; | ||
| 2054 | 2050 | ||
| 2055 | str = (nbytes <= MAX_ALLOCA | 2051 | SAFE_ALLOCA (str, unsigned char *, nbytes); |
| 2056 | ? (unsigned char *) alloca (nbytes) | ||
| 2057 | : (unsigned char *) xmalloc (nbytes)); | ||
| 2058 | bcopy (SDATA (array), str, nbytes); | 2052 | bcopy (SDATA (array), str, nbytes); |
| 2059 | allocate_string_data (XSTRING (array), nchars, | 2053 | allocate_string_data (XSTRING (array), nchars, |
| 2060 | nbytes + new_bytes - prev_bytes); | 2054 | nbytes + new_bytes - prev_bytes); |
| @@ -2062,8 +2056,7 @@ bool-vector. IDX starts at 0. */) | |||
| 2062 | p1 = SDATA (array) + idxval_byte; | 2056 | p1 = SDATA (array) + idxval_byte; |
| 2063 | bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, | 2057 | bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, |
| 2064 | nbytes - (idxval_byte + prev_bytes)); | 2058 | nbytes - (idxval_byte + prev_bytes)); |
| 2065 | if (nbytes > MAX_ALLOCA) | 2059 | SAFE_FREE (nbytes); |
| 2066 | xfree (str); | ||
| 2067 | clear_string_char_byte_cache (); | 2060 | clear_string_char_byte_cache (); |
| 2068 | } | 2061 | } |
| 2069 | while (new_bytes--) | 2062 | while (new_bytes--) |
| @@ -2086,14 +2079,13 @@ bool-vector. IDX starts at 0. */) | |||
| 2086 | unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; | 2079 | unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; |
| 2087 | unsigned char *origstr = SDATA (array), *str; | 2080 | unsigned char *origstr = SDATA (array), *str; |
| 2088 | int nchars, nbytes; | 2081 | int nchars, nbytes; |
| 2082 | USE_SAFE_ALLOCA; | ||
| 2089 | 2083 | ||
| 2090 | nchars = SCHARS (array); | 2084 | nchars = SCHARS (array); |
| 2091 | nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval); | 2085 | nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval); |
| 2092 | nbytes += count_size_as_multibyte (origstr + idxval, | 2086 | nbytes += count_size_as_multibyte (origstr + idxval, |
| 2093 | nchars - idxval); | 2087 | nchars - idxval); |
| 2094 | str = (nbytes <= MAX_ALLOCA | 2088 | SAFE_ALLOCA (str, unsigned char *, nbytes); |
| 2095 | ? (unsigned char *) alloca (nbytes) | ||
| 2096 | : (unsigned char *) xmalloc (nbytes)); | ||
| 2097 | copy_text (SDATA (array), str, nchars, 0, 1); | 2089 | copy_text (SDATA (array), str, nchars, 0, 1); |
| 2098 | PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte, | 2090 | PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte, |
| 2099 | prev_bytes); | 2091 | prev_bytes); |
| @@ -2106,8 +2098,7 @@ bool-vector. IDX starts at 0. */) | |||
| 2106 | *p1++ = *p0++; | 2098 | *p1++ = *p0++; |
| 2107 | bcopy (str + idxval_byte + prev_bytes, p1, | 2099 | bcopy (str + idxval_byte + prev_bytes, p1, |
| 2108 | nbytes - (idxval_byte + prev_bytes)); | 2100 | nbytes - (idxval_byte + prev_bytes)); |
| 2109 | if (nbytes > MAX_ALLOCA) | 2101 | SAFE_FREE (nbytes); |
| 2110 | xfree (str); | ||
| 2111 | clear_string_char_byte_cache (); | 2102 | clear_string_char_byte_cache (); |
| 2112 | } | 2103 | } |
| 2113 | } | 2104 | } |