Re: Smart strings & memory allocation

From: Date: Wed, 18 Jun 2003 12:57:17 +0000
Subject: Re: Smart strings & memory allocation
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-2360@lists.php.net to get a copy of this message
Fine with the concept. If you move the additional check (newlen < SMART_STR_START_SIZE) and preallocation into the if (!(d)->c) branch, the changes won't affect the common code path. > @@ -47,7 +51,11 @@ > if (!(d)->c) (d)->len = (d)->a = 0; \ > newlen = (d)->len + (n); \ > if (newlen >= (d)->a) { \ > + if((d)->a == 0 && newlen < SMART_STR_START_SIZE) { \ > + (d)->a = SMART_STR_START_SIZE; \ > + } else { \ > (d)->a = newlen + SMART_STR_PREALLOC; \ > + } \ > (d)->c = SMART_STR_REALLOC((d)->c, (d)->a + 1, (what)); \ > } \ > } while (0) - Sascha

« previous php.internals (#2360) next »