[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/data.c [lexbind]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/src/data.c [lexbind] |
Date: |
Tue, 06 Jul 2004 07:00:43 -0400 |
Index: emacs/src/data.c
diff -c emacs/src/data.c:1.210.2.11 emacs/src/data.c:1.210.2.12
*** emacs/src/data.c:1.210.2.11 Tue Jul 6 09:14:34 2004
--- emacs/src/data.c Tue Jul 6 10:20:20 2004
***************
*** 2052,2062 ****
}
}
- /* Don't use alloca for relocating string data larger than this, lest
- we overflow their stack. The value is the same as what used in
- fns.c for base64 handling. */
- #define MAX_ALLOCA 16*1024
-
DEFUN ("aset", Faset, Saset, 3, 3, 0,
doc: /* Store into the element of ARRAY at index IDX the value NEWELT.
Return NEWELT. ARRAY may be a vector, a string, a char-table or a
--- 2052,2057 ----
***************
*** 2156,2165 ****
/* We must relocate the string data. */
int nchars = SCHARS (array);
unsigned char *str;
! str = (nbytes <= MAX_ALLOCA
! ? (unsigned char *) alloca (nbytes)
! : (unsigned char *) xmalloc (nbytes));
bcopy (SDATA (array), str, nbytes);
allocate_string_data (XSTRING (array), nchars,
nbytes + new_bytes - prev_bytes);
--- 2151,2159 ----
/* We must relocate the string data. */
int nchars = SCHARS (array);
unsigned char *str;
+ USE_SAFE_ALLOCA;
! SAFE_ALLOCA (str, unsigned char *, nbytes);
bcopy (SDATA (array), str, nbytes);
allocate_string_data (XSTRING (array), nchars,
nbytes + new_bytes - prev_bytes);
***************
*** 2167,2174 ****
p1 = SDATA (array) + idxval_byte;
bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes,
nbytes - (idxval_byte + prev_bytes));
! if (nbytes > MAX_ALLOCA)
! xfree (str);
clear_string_char_byte_cache ();
}
while (new_bytes--)
--- 2161,2167 ----
p1 = SDATA (array) + idxval_byte;
bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes,
nbytes - (idxval_byte + prev_bytes));
! SAFE_FREE (nbytes);
clear_string_char_byte_cache ();
}
while (new_bytes--)
***************
*** 2190,2203 ****
unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1;
unsigned char *origstr = SDATA (array), *str;
int nchars, nbytes;
nchars = SCHARS (array);
nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval);
nbytes += count_size_as_multibyte (origstr + idxval,
nchars - idxval);
! str = (nbytes <= MAX_ALLOCA
! ? (unsigned char *) alloca (nbytes)
! : (unsigned char *) xmalloc (nbytes));
copy_text (SDATA (array), str, nchars, 0, 1);
PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte,
prev_bytes);
--- 2183,2195 ----
unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1;
unsigned char *origstr = SDATA (array), *str;
int nchars, nbytes;
+ USE_SAFE_ALLOCA;
nchars = SCHARS (array);
nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval);
nbytes += count_size_as_multibyte (origstr + idxval,
nchars - idxval);
! SAFE_ALLOCA (str, unsigned char *, nbytes);
copy_text (SDATA (array), str, nchars, 0, 1);
PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte,
prev_bytes);
***************
*** 2210,2217 ****
*p1++ = *p0++;
bcopy (str + idxval_byte + prev_bytes, p1,
nbytes - (idxval_byte + prev_bytes));
! if (nbytes > MAX_ALLOCA)
! xfree (str);
clear_string_char_byte_cache ();
}
}
--- 2202,2208 ----
*p1++ = *p0++;
bcopy (str + idxval_byte + prev_bytes, p1,
nbytes - (idxval_byte + prev_bytes));
! SAFE_FREE (nbytes);
clear_string_char_byte_cache ();
}
}
- [Emacs-diffs] Changes to emacs/src/data.c [lexbind],
Miles Bader <=