aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2004-10-27 06:03:07 +0000
committerMiles Bader2004-10-27 06:03:07 +0000
commit68c015f511f43f6d24ac79ac78cd4a7b3cd5a89e (patch)
treec03104b7ab1750759f40ce18d230093e0ea49824
parente0da2cddda8d2244be17fe33fd3130af8c8041c8 (diff)
parentfce59e4038c02d88aca0ba6ef06db7ceb991d279 (diff)
downloademacs-68c015f511f43f6d24ac79ac78cd4a7b3cd5a89e.tar.gz
emacs-68c015f511f43f6d24ac79ac78cd4a7b3cd5a89e.zip
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
-rw-r--r--src/ChangeLog11
-rw-r--r--src/data.c4
-rw-r--r--src/editfns.c22
-rw-r--r--src/fns.c24
-rw-r--r--src/lisp.h17
-rw-r--r--src/xdisp.c2
6 files changed, 45 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2b0f6922ed6..8c0a7c0bcf1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12004-10-27 Kim F. Storm <storm@cua.dk>
2
3 * editfns.c (Fformat): Allocate discarded table with SAFE_ALLOCA.
4 Only allocate info and discarded tables once.
5
6 * lisp.h (USE_SAFE_ALLOCA): Add and init sa_must_free integer.
7 (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Increment it when malloc is used.
8 (SAFE_FREE): Test it to determine if we need to unwind to free.
9 Remove size arg. All users changed.
10 (SAFE_FREE_LISP) Remove. All users changed to use SAFE_FREE.
11
12004-10-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 122004-10-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2 13
3 * gtkutil.c: Put empty line between comment and function body. 14 * gtkutil.c: Put empty line between comment and function body.
diff --git a/src/data.c b/src/data.c
index dd26feee264..561a034b8fd 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2060,7 +2060,7 @@ bool-vector. IDX starts at 0. */)
2060 p1 = SDATA (array) + idxval_byte; 2060 p1 = SDATA (array) + idxval_byte;
2061 bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, 2061 bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes,
2062 nbytes - (idxval_byte + prev_bytes)); 2062 nbytes - (idxval_byte + prev_bytes));
2063 SAFE_FREE (nbytes); 2063 SAFE_FREE ();
2064 clear_string_char_byte_cache (); 2064 clear_string_char_byte_cache ();
2065 } 2065 }
2066 while (new_bytes--) 2066 while (new_bytes--)
@@ -2102,7 +2102,7 @@ bool-vector. IDX starts at 0. */)
2102 *p1++ = *p0++; 2102 *p1++ = *p0++;
2103 bcopy (str + idxval_byte + prev_bytes, p1, 2103 bcopy (str + idxval_byte + prev_bytes, p1,
2104 nbytes - (idxval_byte + prev_bytes)); 2104 nbytes - (idxval_byte + prev_bytes));
2105 SAFE_FREE (nbytes); 2105 SAFE_FREE ();
2106 clear_string_char_byte_cache (); 2106 clear_string_char_byte_cache ();
2107 } 2107 }
2108 } 2108 }
diff --git a/src/editfns.c b/src/editfns.c
index c3a69fc3f0c..e1482936fe5 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2858,7 +2858,7 @@ It returns the number of characters changed. */)
2858 2858
2859 pos = XINT (start); 2859 pos = XINT (start);
2860 pos_byte = CHAR_TO_BYTE (pos); 2860 pos_byte = CHAR_TO_BYTE (pos);
2861 end_pos = XINT (end); 2861 end_pos = XINT (end);
2862 modify_region (current_buffer, pos, end_pos); 2862 modify_region (current_buffer, pos, end_pos);
2863 2863
2864 cnt = 0; 2864 cnt = 0;
@@ -3387,7 +3387,7 @@ usage: (format STRING &rest OBJECTS) */)
3387 /* discarded[I] is 1 if byte I of the format 3387 /* discarded[I] is 1 if byte I of the format
3388 string was not copied into the output. 3388 string was not copied into the output.
3389 It is 2 if byte I was not the first byte of its character. */ 3389 It is 2 if byte I was not the first byte of its character. */
3390 char *discarded; 3390 char *discarded = 0;
3391 3391
3392 /* Each element records, for one argument, 3392 /* Each element records, for one argument,
3393 the start and end bytepos in the output string, 3393 the start and end bytepos in the output string,
@@ -3438,11 +3438,13 @@ usage: (format STRING &rest OBJECTS) */)
3438 { 3438 {
3439 int nbytes = (nargs+1) * sizeof *info; 3439 int nbytes = (nargs+1) * sizeof *info;
3440 int i; 3440 int i;
3441 info = (struct info *) alloca (nbytes); 3441 if (!info)
3442 info = (struct info *) alloca (nbytes);
3442 bzero (info, nbytes); 3443 bzero (info, nbytes);
3443 for (i = 0; i <= nargs; i++) 3444 for (i = 0; i <= nargs; i++)
3444 info[i].start = -1; 3445 info[i].start = -1;
3445 discarded = (char *) alloca (SBYTES (args[0])); 3446 if (!discarded)
3447 SAFE_ALLOCA (discarded, char *, SBYTES (args[0]));
3446 bzero (discarded, SBYTES (args[0])); 3448 bzero (discarded, SBYTES (args[0]));
3447 } 3449 }
3448 3450
@@ -3803,7 +3805,7 @@ usage: (format STRING &rest OBJECTS) */)
3803 val = make_specified_string (buf, nchars, p - buf, multibyte); 3805 val = make_specified_string (buf, nchars, p - buf, multibyte);
3804 3806
3805 /* If we allocated BUF with malloc, free it too. */ 3807 /* If we allocated BUF with malloc, free it too. */
3806 SAFE_FREE (total); 3808 SAFE_FREE ();
3807 3809
3808 /* If the format string has text properties, or any of the string 3810 /* If the format string has text properties, or any of the string
3809 arguments has text properties, set up text properties of the 3811 arguments has text properties, set up text properties of the
@@ -4187,7 +4189,7 @@ Transposing beyond buffer boundaries is an error. */)
4187 bcopy (start2_addr, temp, len2_byte); 4189 bcopy (start2_addr, temp, len2_byte);
4188 bcopy (start1_addr, start1_addr + len2_byte, len1_byte); 4190 bcopy (start1_addr, start1_addr + len2_byte, len1_byte);
4189 bcopy (temp, start1_addr, len2_byte); 4191 bcopy (temp, start1_addr, len2_byte);
4190 SAFE_FREE (len2_byte); 4192 SAFE_FREE ();
4191 } 4193 }
4192 else 4194 else
4193 /* First region not smaller than second. */ 4195 /* First region not smaller than second. */
@@ -4200,7 +4202,7 @@ Transposing beyond buffer boundaries is an error. */)
4200 bcopy (start1_addr, temp, len1_byte); 4202 bcopy (start1_addr, temp, len1_byte);
4201 bcopy (start2_addr, start1_addr, len2_byte); 4203 bcopy (start2_addr, start1_addr, len2_byte);
4202 bcopy (temp, start1_addr + len2_byte, len1_byte); 4204 bcopy (temp, start1_addr + len2_byte, len1_byte);
4203 SAFE_FREE (len1_byte); 4205 SAFE_FREE ();
4204 } 4206 }
4205 graft_intervals_into_buffer (tmp_interval1, start1 + len2, 4207 graft_intervals_into_buffer (tmp_interval1, start1 + len2,
4206 len1, current_buffer, 0); 4208 len1, current_buffer, 0);
@@ -4236,7 +4238,7 @@ Transposing beyond buffer boundaries is an error. */)
4236 bcopy (start1_addr, temp, len1_byte); 4238 bcopy (start1_addr, temp, len1_byte);
4237 bcopy (start2_addr, start1_addr, len2_byte); 4239 bcopy (start2_addr, start1_addr, len2_byte);
4238 bcopy (temp, start2_addr, len1_byte); 4240 bcopy (temp, start2_addr, len1_byte);
4239 SAFE_FREE (len1_byte); 4241 SAFE_FREE ();
4240 4242
4241 graft_intervals_into_buffer (tmp_interval1, start2, 4243 graft_intervals_into_buffer (tmp_interval1, start2,
4242 len1, current_buffer, 0); 4244 len1, current_buffer, 0);
@@ -4265,7 +4267,7 @@ Transposing beyond buffer boundaries is an error. */)
4265 bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte); 4267 bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte);
4266 safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); 4268 safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid);
4267 bcopy (temp, start1_addr, len2_byte); 4269 bcopy (temp, start1_addr, len2_byte);
4268 SAFE_FREE (len2_byte); 4270 SAFE_FREE ();
4269 4271
4270 graft_intervals_into_buffer (tmp_interval1, end2 - len1, 4272 graft_intervals_into_buffer (tmp_interval1, end2 - len1,
4271 len1, current_buffer, 0); 4273 len1, current_buffer, 0);
@@ -4296,7 +4298,7 @@ Transposing beyond buffer boundaries is an error. */)
4296 bcopy (start2_addr, start1_addr, len2_byte); 4298 bcopy (start2_addr, start1_addr, len2_byte);
4297 bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); 4299 bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid);
4298 bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte); 4300 bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte);
4299 SAFE_FREE (len1_byte); 4301 SAFE_FREE ();
4300 4302
4301 graft_intervals_into_buffer (tmp_interval1, end2 - len1, 4303 graft_intervals_into_buffer (tmp_interval1, end2 - len1,
4302 len1, current_buffer, 0); 4304 len1, current_buffer, 0);
diff --git a/src/fns.c b/src/fns.c
index fe59cb57793..cfbcc83fe8d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -936,7 +936,7 @@ string_make_multibyte (string)
936 0, 1); 936 0, 1);
937 937
938 ret = make_multibyte_string (buf, SCHARS (string), nbytes); 938 ret = make_multibyte_string (buf, SCHARS (string), nbytes);
939 SAFE_FREE (nbytes); 939 SAFE_FREE ();
940 940
941 return ret; 941 return ret;
942} 942}
@@ -969,7 +969,7 @@ string_to_multibyte (string)
969 str_to_multibyte (buf, nbytes, SBYTES (string)); 969 str_to_multibyte (buf, nbytes, SBYTES (string));
970 970
971 ret = make_multibyte_string (buf, SCHARS (string), nbytes); 971 ret = make_multibyte_string (buf, SCHARS (string), nbytes);
972 SAFE_FREE (nbytes); 972 SAFE_FREE ();
973 973
974 return ret; 974 return ret;
975} 975}
@@ -996,7 +996,7 @@ string_make_unibyte (string)
996 1, 0); 996 1, 0);
997 997
998 ret = make_unibyte_string (buf, nchars); 998 ret = make_unibyte_string (buf, nchars);
999 SAFE_FREE (nchars); 999 SAFE_FREE ();
1000 1000
1001 return ret; 1001 return ret;
1002} 1002}
@@ -2489,7 +2489,7 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2489 args[i] = separator; 2489 args[i] = separator;
2490 2490
2491 ret = Fconcat (nargs, args); 2491 ret = Fconcat (nargs, args);
2492 SAFE_FREE_LISP (nargs); 2492 SAFE_FREE ();
2493 2493
2494 return ret; 2494 return ret;
2495} 2495}
@@ -2517,7 +2517,7 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2517 mapcar1 (leni, args, function, sequence); 2517 mapcar1 (leni, args, function, sequence);
2518 2518
2519 ret = Flist (leni, args); 2519 ret = Flist (leni, args);
2520 SAFE_FREE_LISP (leni); 2520 SAFE_FREE ();
2521 2521
2522 return ret; 2522 return ret;
2523} 2523}
@@ -3226,7 +3226,7 @@ into shorter lines. */)
3226 if (encoded_length < 0) 3226 if (encoded_length < 0)
3227 { 3227 {
3228 /* The encoding wasn't possible. */ 3228 /* The encoding wasn't possible. */
3229 SAFE_FREE (allength); 3229 SAFE_FREE ();
3230 error ("Multibyte character in data for base64 encoding"); 3230 error ("Multibyte character in data for base64 encoding");
3231 } 3231 }
3232 3232
@@ -3234,7 +3234,7 @@ into shorter lines. */)
3234 and delete the old. (Insert first in order to preserve markers.) */ 3234 and delete the old. (Insert first in order to preserve markers.) */
3235 SET_PT_BOTH (XFASTINT (beg), ibeg); 3235 SET_PT_BOTH (XFASTINT (beg), ibeg);
3236 insert (encoded, encoded_length); 3236 insert (encoded, encoded_length);
3237 SAFE_FREE (allength); 3237 SAFE_FREE ();
3238 del_range_byte (ibeg + encoded_length, iend + encoded_length, 1); 3238 del_range_byte (ibeg + encoded_length, iend + encoded_length, 1);
3239 3239
3240 /* If point was outside of the region, restore it exactly; else just 3240 /* If point was outside of the region, restore it exactly; else just
@@ -3283,12 +3283,12 @@ into shorter lines. */)
3283 if (encoded_length < 0) 3283 if (encoded_length < 0)
3284 { 3284 {
3285 /* The encoding wasn't possible. */ 3285 /* The encoding wasn't possible. */
3286 SAFE_FREE (allength); 3286 SAFE_FREE ();
3287 error ("Multibyte character in data for base64 encoding"); 3287 error ("Multibyte character in data for base64 encoding");
3288 } 3288 }
3289 3289
3290 encoded_string = make_unibyte_string (encoded, encoded_length); 3290 encoded_string = make_unibyte_string (encoded, encoded_length);
3291 SAFE_FREE (allength); 3291 SAFE_FREE ();
3292 3292
3293 return encoded_string; 3293 return encoded_string;
3294} 3294}
@@ -3431,7 +3431,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3431 if (decoded_length < 0) 3431 if (decoded_length < 0)
3432 { 3432 {
3433 /* The decoding wasn't possible. */ 3433 /* The decoding wasn't possible. */
3434 SAFE_FREE (allength); 3434 SAFE_FREE ();
3435 error ("Invalid base64 data"); 3435 error ("Invalid base64 data");
3436 } 3436 }
3437 3437
@@ -3439,7 +3439,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3439 and delete the old. (Insert first in order to preserve markers.) */ 3439 and delete the old. (Insert first in order to preserve markers.) */
3440 TEMP_SET_PT_BOTH (XFASTINT (beg), ibeg); 3440 TEMP_SET_PT_BOTH (XFASTINT (beg), ibeg);
3441 insert_1_both (decoded, inserted_chars, decoded_length, 0, 1, 0); 3441 insert_1_both (decoded, inserted_chars, decoded_length, 0, 1, 0);
3442 SAFE_FREE (allength); 3442 SAFE_FREE ();
3443 3443
3444 /* Delete the original text. */ 3444 /* Delete the original text. */
3445 del_range_both (PT, PT_BYTE, XFASTINT (end) + inserted_chars, 3445 del_range_both (PT, PT_BYTE, XFASTINT (end) + inserted_chars,
@@ -3483,7 +3483,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3483 else 3483 else
3484 decoded_string = Qnil; 3484 decoded_string = Qnil;
3485 3485
3486 SAFE_FREE (length); 3486 SAFE_FREE ();
3487 if (!STRINGP (decoded_string)) 3487 if (!STRINGP (decoded_string))
3488 error ("Invalid base64 data"); 3488 error ("Invalid base64 data");
3489 3489
diff --git a/src/lisp.h b/src/lisp.h
index 5e4d87595eb..0ab02941c9b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3307,7 +3307,7 @@ extern Lisp_Object Vdirectory_sep_char;
3307extern Lisp_Object safe_alloca_unwind (Lisp_Object); 3307extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3308 3308
3309#define USE_SAFE_ALLOCA \ 3309#define USE_SAFE_ALLOCA \
3310 int sa_count = SPECPDL_INDEX () 3310 int sa_count = SPECPDL_INDEX (), sa_must_free = 0
3311 3311
3312/* SAFE_ALLOCA allocates a simple buffer. */ 3312/* SAFE_ALLOCA allocates a simple buffer. */
3313 3313
@@ -3318,6 +3318,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3318 else \ 3318 else \
3319 { \ 3319 { \
3320 buf = (type) xmalloc (size); \ 3320 buf = (type) xmalloc (size); \
3321 sa_must_free++; \
3321 record_unwind_protect (safe_alloca_unwind, \ 3322 record_unwind_protect (safe_alloca_unwind, \
3322 make_save_value (buf, 0)); \ 3323 make_save_value (buf, 0)); \
3323 } \ 3324 } \
@@ -3325,10 +3326,12 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3325 3326
3326/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ 3327/* SAFE_FREE frees xmalloced memory and enables GC as needed. */
3327 3328
3328#define SAFE_FREE(size) \ 3329#define SAFE_FREE() \
3329 do { \ 3330 do { \
3330 if ((size) >= MAX_ALLOCA) \ 3331 if (sa_must_free) { \
3332 sa_must_free = 0; \
3331 unbind_to (sa_count, Qnil); \ 3333 unbind_to (sa_count, Qnil); \
3334 } \
3332 } while (0) 3335 } while (0)
3333 3336
3334 3337
@@ -3345,17 +3348,11 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3345 buf = (Lisp_Object *) xmalloc (size_); \ 3348 buf = (Lisp_Object *) xmalloc (size_); \
3346 arg_ = make_save_value (buf, nelt); \ 3349 arg_ = make_save_value (buf, nelt); \
3347 XSAVE_VALUE (arg_)->dogc = 1; \ 3350 XSAVE_VALUE (arg_)->dogc = 1; \
3351 sa_must_free++; \
3348 record_unwind_protect (safe_alloca_unwind, arg_); \ 3352 record_unwind_protect (safe_alloca_unwind, arg_); \
3349 } \ 3353 } \
3350 } while (0) 3354 } while (0)
3351 3355
3352#define SAFE_FREE_LISP(nelt) \
3353 do { \
3354 if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \
3355 unbind_to (sa_count, Qnil); \
3356 } while (0)
3357
3358
3359 3356
3360#endif /* EMACS_LISP_H */ 3357#endif /* EMACS_LISP_H */
3361 3358
diff --git a/src/xdisp.c b/src/xdisp.c
index d817e847aa3..799f435c7fb 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -6474,7 +6474,7 @@ add_to_log (format, arg1, arg2)
6474 bcopy (SDATA (msg), buffer, len); 6474 bcopy (SDATA (msg), buffer, len);
6475 6475
6476 message_dolog (buffer, len - 1, 1, 0); 6476 message_dolog (buffer, len - 1, 1, 0);
6477 SAFE_FREE (len); 6477 SAFE_FREE ();
6478 6478
6479 UNGCPRO; 6479 UNGCPRO;
6480} 6480}