ruby-changes:22220
From: nagachika <ko1@a...>
Date: Wed, 11 Jan 2012 23:09:23 +0900 (JST)
Subject: [ruby-changes:22220] nagachika:r34269 (trunk): * gc.c (ruby_mimmalloc): don't set allocated size to header.
nagachika 2012-01-11 23:09:10 +0900 (Wed, 11 Jan 2012) New Revision: 34269 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34269 Log: * gc.c (ruby_mimmalloc): don't set allocated size to header. ruby_mimmalloc() doesn't increment allocated_size/allocations and decrement them in ruby_xfree() cause inconsistency. * gc.c (ruby_xfree): don't decrement allocated_size/allocations if allocated size record is 0. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 34268) +++ ChangeLog (revision 34269) @@ -1,3 +1,12 @@ +Wed Jan 11 22:52:51 2012 CHIKANAGA Tomoyuki <nagachika00@g...> + + * gc.c (ruby_mimmalloc): don't set allocated size to header. + ruby_mimmalloc() doesn't increment allocated_size/allocations and + decrement them in ruby_xfree() cause inconsistency. + + * gc.c (ruby_xfree): don't decrement allocated_size/allocations if + allocated size record is 0. + Wed Jan 11 22:36:43 2012 CHIKANAGA Tomoyuki <nagachika00@g...> * test/readline/test_readline.rb (test_completion_proc_empty_result): Index: gc.c =================================================================== --- gc.c (revision 34268) +++ gc.c (revision 34269) @@ -866,8 +866,10 @@ size_t size; ptr = ((size_t *)ptr) - 1; size = ((size_t*)ptr)[0]; - objspace->malloc_params.allocated_size -= size; - objspace->malloc_params.allocations--; + if (size) { + objspace->malloc_params.allocated_size -= size; + objspace->malloc_params.allocations--; + } #endif free(ptr); @@ -950,7 +952,8 @@ #endif mem = malloc(size); #if CALC_EXACT_MALLOC_SIZE - ((size_t *)mem)[0] = size; + /* set 0 for consistency of allocated_size/allocations */ + ((size_t *)mem)[0] = 0; mem = (size_t *)mem + 1; #endif return mem; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/