Mercurial > hg > xemacs-beta
comparison src/alloc.c @ 1550:6e7ace1ab32d
[xemacs-hg @ 2003-06-30 09:38:38 by stephent]
for big string leak <874r3nryum.fsf@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Mon, 30 Jun 2003 09:38:40 +0000 |
parents | 01c57eb70ae9 |
children | 03009473262a |
comparison
equal
deleted
inserted
replaced
1549:bc9eadea35cf | 1550:6e7ace1ab32d |
---|---|
2088 first_string_chars_block->next = 0; | 2088 first_string_chars_block->next = 0; |
2089 first_string_chars_block->pos = 0; | 2089 first_string_chars_block->pos = 0; |
2090 current_string_chars_block = first_string_chars_block; | 2090 current_string_chars_block = first_string_chars_block; |
2091 } | 2091 } |
2092 | 2092 |
2093 static Ibyte * | |
2094 allocate_big_string_chars (Bytecount length) | |
2095 { | |
2096 Ibyte *p = xnew_array (Ibyte, length); | |
2097 INCREMENT_CONS_COUNTER (length, "string chars"); | |
2098 return p; | |
2099 } | |
2100 | |
2093 static struct string_chars * | 2101 static struct string_chars * |
2094 allocate_string_chars_struct (Lisp_Object string_it_goes_with, | 2102 allocate_string_chars_struct (Lisp_Object string_it_goes_with, |
2095 Bytecount fullsize) | 2103 Bytecount fullsize) |
2096 { | 2104 { |
2097 struct string_chars *s_chars; | 2105 struct string_chars *s_chars; |
2162 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); | 2170 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); |
2163 xzero (*s); | 2171 xzero (*s); |
2164 set_lheader_implementation (&s->u.lheader, &lrecord_string); | 2172 set_lheader_implementation (&s->u.lheader, &lrecord_string); |
2165 | 2173 |
2166 set_lispstringp_data (s, BIG_STRING_FULLSIZE_P (fullsize) | 2174 set_lispstringp_data (s, BIG_STRING_FULLSIZE_P (fullsize) |
2167 ? xnew_array (Ibyte, length + 1) | 2175 ? allocate_big_string_chars (length + 1) |
2168 : allocate_string_chars_struct (wrap_string (s), | 2176 : allocate_string_chars_struct (wrap_string (s), |
2169 fullsize)->chars); | 2177 fullsize)->chars); |
2170 | 2178 |
2171 set_lispstringp_length (s, length); | 2179 set_lispstringp_length (s, length); |
2172 s->plist = Qnil; | 2180 s->plist = Qnil; |
2238 (s, (Ibyte *) xrealloc (XSTRING_DATA (s), | 2246 (s, (Ibyte *) xrealloc (XSTRING_DATA (s), |
2239 XSTRING_LENGTH (s) + delta + 1)); | 2247 XSTRING_LENGTH (s) + delta + 1)); |
2240 if (delta > 0 && pos >= 0) | 2248 if (delta > 0 && pos >= 0) |
2241 memmove (XSTRING_DATA (s) + pos + delta, XSTRING_DATA (s) + pos, | 2249 memmove (XSTRING_DATA (s) + pos + delta, XSTRING_DATA (s) + pos, |
2242 len); | 2250 len); |
2251 /* Bump the cons counter. | |
2252 Conservative; Martin let the increment be delta. */ | |
2253 INCREMENT_CONS_COUNTER (newfullsize, "string chars"); | |
2243 } | 2254 } |
2244 else /* String has been demoted from BIG_STRING. */ | 2255 else /* String has been demoted from BIG_STRING. */ |
2245 { | 2256 { |
2246 Ibyte *new_data = | 2257 Ibyte *new_data = |
2247 allocate_string_chars_struct (s, newfullsize)->chars; | 2258 allocate_string_chars_struct (s, newfullsize)->chars; |
2278 else | 2289 else |
2279 { | 2290 { |
2280 Ibyte *old_data = XSTRING_DATA (s); | 2291 Ibyte *old_data = XSTRING_DATA (s); |
2281 Ibyte *new_data = | 2292 Ibyte *new_data = |
2282 BIG_STRING_FULLSIZE_P (newfullsize) | 2293 BIG_STRING_FULLSIZE_P (newfullsize) |
2283 ? xnew_array (Ibyte, XSTRING_LENGTH (s) + delta + 1) | 2294 ? allocate_big_string_chars (XSTRING_LENGTH (s) + delta + 1) |
2284 : allocate_string_chars_struct (s, newfullsize)->chars; | 2295 : allocate_string_chars_struct (s, newfullsize)->chars; |
2285 | 2296 |
2286 if (pos >= 0) | 2297 if (pos >= 0) |
2287 { | 2298 { |
2288 memcpy (new_data, old_data, pos); | 2299 memcpy (new_data, old_data, pos); |