From 230dcf2e265eb88a4b9a57d83c845128c81d933d Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Fri, 17 Feb 2006 10:55:03 +0000 Subject: [PATCH] - Moved an allocation size roundup operation in realloc(). git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15082 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/changes | 2 ++ library/stdlib_realloc.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) 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