diff --git a/library/changes b/library/changes index 2b7959b..0123503 100644 --- a/library/changes +++ b/library/changes @@ -13,6 +13,8 @@ - The printf() family stripped trailing zeroes from the integer part of %g output. Fixed. +- Moved an allocation size roundup operation in realloc(). + c.lib 1.198 (11.12.2005) diff --git a/library/stdlib_realloc.c b/library/stdlib_realloc.c index b3edc49..53ae1a4 100644 --- a/library/stdlib_realloc.c +++ b/library/stdlib_realloc.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_realloc.c,v 1.9 2006-01-08 12:04:26 obarthel Exp $ + * $Id: stdlib_realloc.c,v 1.10 2006-02-17 10:55:03 obarthel Exp $ * * :ts=4 * @@ -122,21 +122,21 @@ __realloc(void *ptr,size_t size,const char * file,int line) } #else { - if(size > mn->mn_Size) + size_t rounded_allocation_size; + + /* Round the total allocation size to the operating system + granularity. */ + rounded_allocation_size = __get_allocation_size(size); + + assert( rounded_allocation_size >= size ); + + if(rounded_allocation_size > mn->mn_Size) { /* Allocation size should grow. */ reallocate = TRUE; } else { - size_t rounded_allocation_size; - - /* Round the total allocation size to the operating system - granularity. */ - rounded_allocation_size = __get_allocation_size(size); - - assert( rounded_allocation_size >= size ); - /* Optimization: If the block size shrinks by less than half the original allocation size, do not reallocate the block and do not copy over the contents of the old