Mercurial > emacs
changeset 90038:3a5b83e18d41
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-66
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-642
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 27 Oct 2004 06:03:07 +0000 |
parents | 0fe073a08cef (current diff) c3945be39e09 (diff) |
children | 67146244da43 |
files | src/ChangeLog src/data.c src/editfns.c src/fns.c src/lisp.h src/xdisp.c |
diffstat | 6 files changed, 45 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Wed Oct 27 05:42:04 2004 +0000 +++ b/src/ChangeLog Wed Oct 27 06:03:07 2004 +0000 @@ -1,3 +1,14 @@ +2004-10-27 Kim F. Storm <storm@cua.dk> + + * editfns.c (Fformat): Allocate discarded table with SAFE_ALLOCA. + Only allocate info and discarded tables once. + + * lisp.h (USE_SAFE_ALLOCA): Add and init sa_must_free integer. + (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Increment it when malloc is used. + (SAFE_FREE): Test it to determine if we need to unwind to free. + Remove size arg. All users changed. + (SAFE_FREE_LISP) Remove. All users changed to use SAFE_FREE. + 2004-10-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> * gtkutil.c: Put empty line between comment and function body.
--- a/src/data.c Wed Oct 27 05:42:04 2004 +0000 +++ b/src/data.c Wed Oct 27 06:03:07 2004 +0000 @@ -2060,7 +2060,7 @@ p1 = SDATA (array) + idxval_byte; bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, nbytes - (idxval_byte + prev_bytes)); - SAFE_FREE (nbytes); + SAFE_FREE (); clear_string_char_byte_cache (); } while (new_bytes--) @@ -2102,7 +2102,7 @@ *p1++ = *p0++; bcopy (str + idxval_byte + prev_bytes, p1, nbytes - (idxval_byte + prev_bytes)); - SAFE_FREE (nbytes); + SAFE_FREE (); clear_string_char_byte_cache (); } }
--- a/src/editfns.c Wed Oct 27 05:42:04 2004 +0000 +++ b/src/editfns.c Wed Oct 27 06:03:07 2004 +0000 @@ -2858,7 +2858,7 @@ pos = XINT (start); pos_byte = CHAR_TO_BYTE (pos); - end_pos = XINT (end); + end_pos = XINT (end); modify_region (current_buffer, pos, end_pos); cnt = 0; @@ -3387,7 +3387,7 @@ /* discarded[I] is 1 if byte I of the format string was not copied into the output. It is 2 if byte I was not the first byte of its character. */ - char *discarded; + char *discarded = 0; /* Each element records, for one argument, the start and end bytepos in the output string, @@ -3438,11 +3438,13 @@ { int nbytes = (nargs+1) * sizeof *info; int i; - info = (struct info *) alloca (nbytes); + if (!info) + info = (struct info *) alloca (nbytes); bzero (info, nbytes); for (i = 0; i <= nargs; i++) info[i].start = -1; - discarded = (char *) alloca (SBYTES (args[0])); + if (!discarded) + SAFE_ALLOCA (discarded, char *, SBYTES (args[0])); bzero (discarded, SBYTES (args[0])); } @@ -3803,7 +3805,7 @@ val = make_specified_string (buf, nchars, p - buf, multibyte); /* If we allocated BUF with malloc, free it too. */ - SAFE_FREE (total); + SAFE_FREE (); /* If the format string has text properties, or any of the string arguments has text properties, set up text properties of the @@ -4187,7 +4189,7 @@ bcopy (start2_addr, temp, len2_byte); bcopy (start1_addr, start1_addr + len2_byte, len1_byte); bcopy (temp, start1_addr, len2_byte); - SAFE_FREE (len2_byte); + SAFE_FREE (); } else /* First region not smaller than second. */ @@ -4200,7 +4202,7 @@ bcopy (start1_addr, temp, len1_byte); bcopy (start2_addr, start1_addr, len2_byte); bcopy (temp, start1_addr + len2_byte, len1_byte); - SAFE_FREE (len1_byte); + SAFE_FREE (); } graft_intervals_into_buffer (tmp_interval1, start1 + len2, len1, current_buffer, 0); @@ -4236,7 +4238,7 @@ bcopy (start1_addr, temp, len1_byte); bcopy (start2_addr, start1_addr, len2_byte); bcopy (temp, start2_addr, len1_byte); - SAFE_FREE (len1_byte); + SAFE_FREE (); graft_intervals_into_buffer (tmp_interval1, start2, len1, current_buffer, 0); @@ -4265,7 +4267,7 @@ bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte); safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); bcopy (temp, start1_addr, len2_byte); - SAFE_FREE (len2_byte); + SAFE_FREE (); graft_intervals_into_buffer (tmp_interval1, end2 - len1, len1, current_buffer, 0); @@ -4296,7 +4298,7 @@ bcopy (start2_addr, start1_addr, len2_byte); bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte); - SAFE_FREE (len1_byte); + SAFE_FREE (); graft_intervals_into_buffer (tmp_interval1, end2 - len1, len1, current_buffer, 0);
--- a/src/fns.c Wed Oct 27 05:42:04 2004 +0000 +++ b/src/fns.c Wed Oct 27 06:03:07 2004 +0000 @@ -936,7 +936,7 @@ 0, 1); ret = make_multibyte_string (buf, SCHARS (string), nbytes); - SAFE_FREE (nbytes); + SAFE_FREE (); return ret; } @@ -969,7 +969,7 @@ str_to_multibyte (buf, nbytes, SBYTES (string)); ret = make_multibyte_string (buf, SCHARS (string), nbytes); - SAFE_FREE (nbytes); + SAFE_FREE (); return ret; } @@ -996,7 +996,7 @@ 1, 0); ret = make_unibyte_string (buf, nchars); - SAFE_FREE (nchars); + SAFE_FREE (); return ret; } @@ -2489,7 +2489,7 @@ args[i] = separator; ret = Fconcat (nargs, args); - SAFE_FREE_LISP (nargs); + SAFE_FREE (); return ret; } @@ -2517,7 +2517,7 @@ mapcar1 (leni, args, function, sequence); ret = Flist (leni, args); - SAFE_FREE_LISP (leni); + SAFE_FREE (); return ret; } @@ -3226,7 +3226,7 @@ if (encoded_length < 0) { /* The encoding wasn't possible. */ - SAFE_FREE (allength); + SAFE_FREE (); error ("Multibyte character in data for base64 encoding"); } @@ -3234,7 +3234,7 @@ and delete the old. (Insert first in order to preserve markers.) */ SET_PT_BOTH (XFASTINT (beg), ibeg); insert (encoded, encoded_length); - SAFE_FREE (allength); + SAFE_FREE (); del_range_byte (ibeg + encoded_length, iend + encoded_length, 1); /* If point was outside of the region, restore it exactly; else just @@ -3283,12 +3283,12 @@ if (encoded_length < 0) { /* The encoding wasn't possible. */ - SAFE_FREE (allength); + SAFE_FREE (); error ("Multibyte character in data for base64 encoding"); } encoded_string = make_unibyte_string (encoded, encoded_length); - SAFE_FREE (allength); + SAFE_FREE (); return encoded_string; } @@ -3431,7 +3431,7 @@ if (decoded_length < 0) { /* The decoding wasn't possible. */ - SAFE_FREE (allength); + SAFE_FREE (); error ("Invalid base64 data"); } @@ -3439,7 +3439,7 @@ and delete the old. (Insert first in order to preserve markers.) */ TEMP_SET_PT_BOTH (XFASTINT (beg), ibeg); insert_1_both (decoded, inserted_chars, decoded_length, 0, 1, 0); - SAFE_FREE (allength); + SAFE_FREE (); /* Delete the original text. */ del_range_both (PT, PT_BYTE, XFASTINT (end) + inserted_chars, @@ -3483,7 +3483,7 @@ else decoded_string = Qnil; - SAFE_FREE (length); + SAFE_FREE (); if (!STRINGP (decoded_string)) error ("Invalid base64 data");
--- a/src/lisp.h Wed Oct 27 05:42:04 2004 +0000 +++ b/src/lisp.h Wed Oct 27 06:03:07 2004 +0000 @@ -3307,7 +3307,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); #define USE_SAFE_ALLOCA \ - int sa_count = SPECPDL_INDEX () + int sa_count = SPECPDL_INDEX (), sa_must_free = 0 /* SAFE_ALLOCA allocates a simple buffer. */ @@ -3318,6 +3318,7 @@ else \ { \ buf = (type) xmalloc (size); \ + sa_must_free++; \ record_unwind_protect (safe_alloca_unwind, \ make_save_value (buf, 0)); \ } \ @@ -3325,10 +3326,12 @@ /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ -#define SAFE_FREE(size) \ +#define SAFE_FREE() \ do { \ - if ((size) >= MAX_ALLOCA) \ + if (sa_must_free) { \ + sa_must_free = 0; \ unbind_to (sa_count, Qnil); \ + } \ } while (0) @@ -3345,17 +3348,11 @@ buf = (Lisp_Object *) xmalloc (size_); \ arg_ = make_save_value (buf, nelt); \ XSAVE_VALUE (arg_)->dogc = 1; \ + sa_must_free++; \ record_unwind_protect (safe_alloca_unwind, arg_); \ } \ } while (0) -#define SAFE_FREE_LISP(nelt) \ - do { \ - if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \ - unbind_to (sa_count, Qnil); \ - } while (0) - - #endif /* EMACS_LISP_H */