aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2004-10-26 22:37:34 +0000
committerKim F. Storm2004-10-26 22:37:34 +0000
commite65837df545fcf0791b3c8db27186e605cf89538 (patch)
tree376592bc72b4a057aa22f920993a3589b089d1a8 /src
parentc33188d937816a0c9dbbc271db54525fee73170b (diff)
downloademacs-e65837df545fcf0791b3c8db27186e605cf89538.tar.gz
emacs-e65837df545fcf0791b3c8db27186e605cf89538.zip
(Fformat): Allocate discarded table with SAFE_ALLOCA.
Only allocate info and discarded tables once. Fix SAFE_FREE calls.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 5b129a18a62..72d333081fa 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2775,7 +2775,7 @@ It returns the number of characters changed. */)
2775 2775
2776 pos = XINT (start); 2776 pos = XINT (start);
2777 pos_byte = CHAR_TO_BYTE (pos); 2777 pos_byte = CHAR_TO_BYTE (pos);
2778 end_pos = XINT (end); 2778 end_pos = XINT (end);
2779 modify_region (current_buffer, pos, XINT (end)); 2779 modify_region (current_buffer, pos, XINT (end));
2780 2780
2781 cnt = 0; 2781 cnt = 0;
@@ -3268,7 +3268,7 @@ usage: (format STRING &rest OBJECTS) */)
3268 /* discarded[I] is 1 if byte I of the format 3268 /* discarded[I] is 1 if byte I of the format
3269 string was not copied into the output. 3269 string was not copied into the output.
3270 It is 2 if byte I was not the first byte of its character. */ 3270 It is 2 if byte I was not the first byte of its character. */
3271 char *discarded; 3271 char *discarded = 0;
3272 3272
3273 /* Each element records, for one argument, 3273 /* Each element records, for one argument,
3274 the start and end bytepos in the output string, 3274 the start and end bytepos in the output string,
@@ -3319,11 +3319,13 @@ usage: (format STRING &rest OBJECTS) */)
3319 { 3319 {
3320 int nbytes = (nargs+1) * sizeof *info; 3320 int nbytes = (nargs+1) * sizeof *info;
3321 int i; 3321 int i;
3322 info = (struct info *) alloca (nbytes); 3322 if (!info)
3323 info = (struct info *) alloca (nbytes);
3323 bzero (info, nbytes); 3324 bzero (info, nbytes);
3324 for (i = 0; i <= nargs; i++) 3325 for (i = 0; i <= nargs; i++)
3325 info[i].start = -1; 3326 info[i].start = -1;
3326 discarded = (char *) alloca (SBYTES (args[0])); 3327 if (!discarded)
3328 SAFE_ALLOCA (discarded, char *, SBYTES (args[0]));
3327 bzero (discarded, SBYTES (args[0])); 3329 bzero (discarded, SBYTES (args[0]));
3328 } 3330 }
3329 3331
@@ -3684,7 +3686,7 @@ usage: (format STRING &rest OBJECTS) */)
3684 val = make_specified_string (buf, nchars, p - buf, multibyte); 3686 val = make_specified_string (buf, nchars, p - buf, multibyte);
3685 3687
3686 /* If we allocated BUF with malloc, free it too. */ 3688 /* If we allocated BUF with malloc, free it too. */
3687 SAFE_FREE (total); 3689 SAFE_FREE ();
3688 3690
3689 /* If the format string has text properties, or any of the string 3691 /* If the format string has text properties, or any of the string
3690 arguments has text properties, set up text properties of the 3692 arguments has text properties, set up text properties of the
@@ -4056,7 +4058,7 @@ Transposing beyond buffer boundaries is an error. */)
4056 bcopy (start2_addr, temp, len2_byte); 4058 bcopy (start2_addr, temp, len2_byte);
4057 bcopy (start1_addr, start1_addr + len2_byte, len1_byte); 4059 bcopy (start1_addr, start1_addr + len2_byte, len1_byte);
4058 bcopy (temp, start1_addr, len2_byte); 4060 bcopy (temp, start1_addr, len2_byte);
4059 SAFE_FREE (len2_byte); 4061 SAFE_FREE ();
4060 } 4062 }
4061 else 4063 else
4062 /* First region not smaller than second. */ 4064 /* First region not smaller than second. */
@@ -4069,7 +4071,7 @@ Transposing beyond buffer boundaries is an error. */)
4069 bcopy (start1_addr, temp, len1_byte); 4071 bcopy (start1_addr, temp, len1_byte);
4070 bcopy (start2_addr, start1_addr, len2_byte); 4072 bcopy (start2_addr, start1_addr, len2_byte);
4071 bcopy (temp, start1_addr + len2_byte, len1_byte); 4073 bcopy (temp, start1_addr + len2_byte, len1_byte);
4072 SAFE_FREE (len1_byte); 4074 SAFE_FREE ();
4073 } 4075 }
4074 graft_intervals_into_buffer (tmp_interval1, start1 + len2, 4076 graft_intervals_into_buffer (tmp_interval1, start1 + len2,
4075 len1, current_buffer, 0); 4077 len1, current_buffer, 0);
@@ -4105,7 +4107,7 @@ Transposing beyond buffer boundaries is an error. */)
4105 bcopy (start1_addr, temp, len1_byte); 4107 bcopy (start1_addr, temp, len1_byte);
4106 bcopy (start2_addr, start1_addr, len2_byte); 4108 bcopy (start2_addr, start1_addr, len2_byte);
4107 bcopy (temp, start2_addr, len1_byte); 4109 bcopy (temp, start2_addr, len1_byte);
4108 SAFE_FREE (len1_byte); 4110 SAFE_FREE ();
4109 4111
4110 graft_intervals_into_buffer (tmp_interval1, start2, 4112 graft_intervals_into_buffer (tmp_interval1, start2,
4111 len1, current_buffer, 0); 4113 len1, current_buffer, 0);
@@ -4134,7 +4136,7 @@ Transposing beyond buffer boundaries is an error. */)
4134 bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte); 4136 bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte);
4135 safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); 4137 safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid);
4136 bcopy (temp, start1_addr, len2_byte); 4138 bcopy (temp, start1_addr, len2_byte);
4137 SAFE_FREE (len2_byte); 4139 SAFE_FREE ();
4138 4140
4139 graft_intervals_into_buffer (tmp_interval1, end2 - len1, 4141 graft_intervals_into_buffer (tmp_interval1, end2 - len1,
4140 len1, current_buffer, 0); 4142 len1, current_buffer, 0);
@@ -4165,7 +4167,7 @@ Transposing beyond buffer boundaries is an error. */)
4165 bcopy (start2_addr, start1_addr, len2_byte); 4167 bcopy (start2_addr, start1_addr, len2_byte);
4166 bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); 4168 bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid);
4167 bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte); 4169 bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte);
4168 SAFE_FREE (len1_byte); 4170 SAFE_FREE ();
4169 4171
4170 graft_intervals_into_buffer (tmp_interval1, end2 - len1, 4172 graft_intervals_into_buffer (tmp_interval1, end2 - len1,
4171 len1, current_buffer, 0); 4173 len1, current_buffer, 0);