# HG changeset patch # User stephent # Date 1056965920 0 # Node ID 6e7ace1ab32d923acb1dbf18ca571692495643e5 # Parent bc9eadea35cf181e95bd88dd0651ddc7843c749c [xemacs-hg @ 2003-06-30 09:38:38 by stephent] for big string leak <874r3nryum.fsf@tleepslib.sk.tsukuba.ac.jp> diff -r bc9eadea35cf -r 6e7ace1ab32d src/ChangeLog --- a/src/ChangeLog Mon Jun 30 09:31:01 2003 +0000 +++ b/src/ChangeLog Mon Jun 30 09:38:40 2003 +0000 @@ -1,3 +1,12 @@ +2003-05-22 Stephen J. Turnbull + + * alloc.c (allocate_big_string_chars): New. + (make_uninit_string): Use it. + (resize_string): Use it. Bump cons counter on realloc, too. + + Based on analysis and patch by Martin Buchholz : + <15409.4809.288773.686482@gargle.gargle.HOWL>. + 2003-06-01 Steve Youngs * XEmacs 21.5.14 "cassava" is released. diff -r bc9eadea35cf -r 6e7ace1ab32d src/alloc.c --- a/src/alloc.c Mon Jun 30 09:31:01 2003 +0000 +++ b/src/alloc.c Mon Jun 30 09:38:40 2003 +0000 @@ -2090,6 +2090,14 @@ current_string_chars_block = first_string_chars_block; } +static Ibyte * +allocate_big_string_chars (Bytecount length) +{ + Ibyte *p = xnew_array (Ibyte, length); + INCREMENT_CONS_COUNTER (length, "string chars"); + return p; +} + static struct string_chars * allocate_string_chars_struct (Lisp_Object string_it_goes_with, Bytecount fullsize) @@ -2164,7 +2172,7 @@ set_lheader_implementation (&s->u.lheader, &lrecord_string); set_lispstringp_data (s, BIG_STRING_FULLSIZE_P (fullsize) - ? xnew_array (Ibyte, length + 1) + ? allocate_big_string_chars (length + 1) : allocate_string_chars_struct (wrap_string (s), fullsize)->chars); @@ -2240,6 +2248,9 @@ if (delta > 0 && pos >= 0) memmove (XSTRING_DATA (s) + pos + delta, XSTRING_DATA (s) + pos, len); + /* Bump the cons counter. + Conservative; Martin let the increment be delta. */ + INCREMENT_CONS_COUNTER (newfullsize, "string chars"); } else /* String has been demoted from BIG_STRING. */ { @@ -2280,7 +2291,7 @@ Ibyte *old_data = XSTRING_DATA (s); Ibyte *new_data = BIG_STRING_FULLSIZE_P (newfullsize) - ? xnew_array (Ibyte, XSTRING_LENGTH (s) + delta + 1) + ? allocate_big_string_chars (XSTRING_LENGTH (s) + delta + 1) : allocate_string_chars_struct (s, newfullsize)->chars; if (pos >= 0)