diff options
Diffstat (limited to 'Zend/zend_string.h')
-rw-r--r-- | Zend/zend_string.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 5226c06e79..af83d4d3b5 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -54,6 +54,8 @@ END_EXTERN_C() #define STR_RELEASE(s) zend_str_release(s) #define STR_EMPTY_ALLOC() CG(empty_string) +#define _STR_HEADER_SIZE XtOffsetOf(zend_string, val) + static zend_always_inline zend_ulong zend_str_hash_val(zend_string *s) { if (!s->h) { @@ -93,7 +95,7 @@ static zend_always_inline zend_uint zend_str_delref(zend_string *s) static zend_always_inline zend_string *zend_str_alloc(int len, int persistent) { - zend_string *ret = pemalloc(sizeof(zend_string) + len, persistent); + zend_string *ret = pemalloc(_STR_HEADER_SIZE + len + 1, persistent); GC_REFCOUNT(ret) = 1; #if 1 @@ -111,7 +113,7 @@ static zend_always_inline zend_string *zend_str_alloc(int len, int persistent) static zend_always_inline zend_string *zend_str_safe_alloc(size_t n, size_t m, size_t l, int persistent) { - zend_string *ret = safe_pemalloc(n, m, sizeof(zend_string) + l - 1, persistent); + zend_string *ret = safe_pemalloc(n, m, _STR_HEADER_SIZE + l + 1, persistent); GC_REFCOUNT(ret) = 1; #if 1 @@ -161,7 +163,7 @@ static zend_always_inline zend_string *zend_str_realloc(zend_string *s, int len, ret = STR_ALLOC(len, persistent); memcpy(ret->val, s->val, (len > s->len ? s->len : len) + 1); } else if (STR_REFCOUNT(s) == 1) { - ret = perealloc(s, sizeof(zend_string) + len, persistent); + ret = perealloc(s, _STR_HEADER_SIZE + len + 1, persistent); ret->len = len; STR_FORGET_HASH_VAL(ret); } else { @@ -180,7 +182,7 @@ static zend_always_inline zend_string *zend_str_safe_realloc(zend_string *s, siz ret = STR_SAFE_ALLOC(n, m, l, persistent); memcpy(ret->val, s->val, ((n * m) + l > s->len ? s->len : ((n * m) + l)) + 1); } else if (STR_REFCOUNT(s) == 1) { - ret = safe_perealloc(s, n, m, sizeof(zend_string) + l - 1, persistent); + ret = safe_perealloc(s, n, m, _STR_HEADER_SIZE + l + 1, persistent); ret->len = (n * m) + l; STR_FORGET_HASH_VAL(ret); } else { |