diff options
author | Sascha Schumann <sas@php.net> | 2003-06-18 16:15:47 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2003-06-18 16:15:47 +0000 |
commit | be4947b0e6194f3636dd326f7fa43df1d6a5391e (patch) | |
tree | 6037f4ca488725d55d11d3da0a169db6c24b34ef /ext/standard/php_smart_str.h | |
parent | d860759db9f51b5a1683e5a12f92755a0384c16e (diff) | |
download | php-git-be4947b0e6194f3636dd326f7fa43df1d6a5391e.tar.gz |
Use a smaller default size to accomodate the engine
Submitted by: Stanislav Malyshev, with some massaging by me
Diffstat (limited to 'ext/standard/php_smart_str.h')
-rw-r--r-- | ext/standard/php_smart_str.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h index d84f54c626..9bd6475759 100644 --- a/ext/standard/php_smart_str.h +++ b/ext/standard/php_smart_str.h @@ -36,19 +36,33 @@ #define SMART_STR_PREALLOC 128 #endif +#ifndef SMART_STR_START_SIZE +#define SMART_STR_START_SIZE 78 +#endif + #ifdef SMART_STR_USE_REALLOC #define SMART_STR_REALLOC(a,b,c) realloc((a),(b)) #else #define SMART_STR_REALLOC(a,b,c) perealloc((a),(b),(c)) #endif +#define SMART_STR_DO_REALLOC(d, what) \ + (d)->c = SMART_STR_REALLOC((d)->c, (d)->a + 1, (what)) #define smart_str_alloc4(d, n, what, newlen) do { \ - if (!(d)->c) (d)->len = (d)->a = 0; \ - newlen = (d)->len + (n); \ - if (newlen >= (d)->a) { \ - (d)->a = newlen + SMART_STR_PREALLOC; \ - (d)->c = SMART_STR_REALLOC((d)->c, (d)->a + 1, (what)); \ + if (!(d)->c) { \ + (d)->len = 0; \ + newlen = (n); \ + (d)->a = newlen < SMART_STR_START_SIZE \ + ? SMART_STR_START_SIZE \ + : newlen + SMART_STR_PREALLOC; \ + SMART_STR_DO_REALLOC(d, what); \ + } else { \ + newlen = (d)->len + (n); \ + if (newlen >= (d)->a) { \ + (d)->a = newlen + SMART_STR_PREALLOC; \ + SMART_STR_DO_REALLOC(d, what); \ + } \ } \ } while (0) |