http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.287&r2=1.288&ty=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.287 ZendEngine2/zend.c:1.288 --- ZendEngine2/zend.c:1.287 Mon Jul 12 12:38:45 2004 +++ ZendEngine2/zend.c Mon Jul 19 03:19:00 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.287 2004/07/12 16:38:45 andi Exp $ */ +/* $Id: zend.c,v 1.288 2004/07/19 07:19:00 andi Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -194,7 +194,7 @@ switch (expr->type) { case IS_NULL: expr_copy->value.str.len = 0; - expr_copy->value.str.val = empty_string; + expr_copy->value.str.val = STR_EMPTY_ALLOC(); break; case IS_BOOL: if (expr->value.lval) { @@ -202,7 +202,7 @@ expr_copy->value.str.val = estrndup("1", 1); } else { expr_copy->value.str.len = 0; - expr_copy->value.str.val = empty_string; + expr_copy->value.str.val = STR_EMPTY_ALLOC(); } break; case IS_RESOURCE: @@ -242,7 +242,7 @@ if (EG(exception)) { zval_dtor(expr_copy); expr_copy->value.str.len = 0; - expr_copy->value.str.val = empty_string; + expr_copy->value.str.val = STR_EMPTY_ALLOC(); break; } } http://cvs.php.net/diff.php/ZendEngine2/zend.h?r1=1.257&r2=1.258&ty=u Index: ZendEngine2/zend.h diff -u ZendEngine2/zend.h:1.257 ZendEngine2/zend.h:1.258 --- ZendEngine2/zend.h:1.257 Tue Jul 13 15:56:49 2004 +++ ZendEngine2/zend.h Mon Jul 19 03:19:00 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.257 2004/07/13 19:56:49 andi Exp $ */ +/* $Id: zend.h,v 1.258 2004/07/19 07:19:00 andi Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -460,22 +460,19 @@ #define Z_DBG(expr) #endif -ZEND_API extern char *empty_string; - BEGIN_EXTERN_C() ZEND_API void free_estring(char **str_p); END_EXTERN_C() -#define STR_FREE(ptr) if (ptr && ptr!=empty_string) { efree(ptr); } -#define STR_FREE_REL(ptr) if (ptr && ptr!=empty_string) { efree_rel(ptr); } +/* FIXME: Check if we can save if (ptr) too */ -#define STR_REALLOC(ptr, size) \ - if (ptr!=empty_string) { \ - ptr = (char *) erealloc(ptr, size); \ - } else { \ - ptr = (char *) emalloc(size); \ - memset(ptr, 0, size); \ - } +#define STR_FREE(ptr) if (ptr) { efree(ptr); } +#define STR_FREE_REL(ptr) if (ptr) { efree_rel(ptr); } + +#define STR_EMPTY_ALLOC() estrndup("", sizeof("")-1) + +#define STR_REALLOC(ptr, size) \ + ptr = (char *) erealloc(ptr, size); /* output support */ #define ZEND_WRITE(str, str_len) zend_write((str), (str_len)) http://cvs.php.net/diff.php/ZendEngine2/zend_API.h?r1=1.185&r2=1.186&ty=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.185 ZendEngine2/zend_API.h:1.186 --- ZendEngine2/zend_API.h:1.185 Thu Jun 10 08:32:09 2004 +++ ZendEngine2/zend_API.h Mon Jul 19 03:19:00 2004 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.185 2004/06/10 12:32:09 helly Exp $ */ +/* $Id: zend_API.h,v 1.186 2004/07/19 07:19:00 andi Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -385,7 +385,7 @@ #define ZVAL_EMPTY_STRING(z) { \ (z)->value.str.len = 0; \ - (z)->value.str.val = empty_string; \ + (z)->value.str.val = STR_EMPTY_ALLOC(); \ (z)->type = IS_STRING; \ } http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.h?r1=1.53&r2=1.54&ty=u Index: ZendEngine2/zend_alloc.h diff -u ZendEngine2/zend_alloc.h:1.53 ZendEngine2/zend_alloc.h:1.54 --- ZendEngine2/zend_alloc.h:1.53 Thu Jul 15 18:59:54 2004 +++ ZendEngine2/zend_alloc.h Mon Jul 19 03:19:01 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_alloc.h,v 1.53 2004/07/15 22:59:54 andi Exp $ */ +/* $Id: zend_alloc.h,v 1.54 2004/07/19 07:19:01 andi Exp $ */ #ifndef ZEND_ALLOC_H #define ZEND_ALLOC_H @@ -119,8 +119,8 @@ #define perealloc_recoverable_rel(ptr, size, persistent) ((persistent)?realloc((ptr), (size)):erealloc_recoverable_rel((ptr), (size))) #define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s)) -#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):(empty_string)) -#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):(empty_string)) +#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):STR_EMPTY_ALLOC()) +#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):STR_EMPTY_ALLOC()) ZEND_API int zend_set_memory_limit(unsigned int memory_limit); http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.653&r2=1.654&ty=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.653 ZendEngine2/zend_execute.c:1.654 --- ZendEngine2/zend_execute.c:1.653 Fri Jul 16 02:39:50 2004 +++ ZendEngine2/zend_execute.c Mon Jul 19 03:19:01 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.653 2004/07/16 06:39:50 helly Exp $ */ +/* $Id: zend_execute.c,v 1.654 2004/07/19 07:19:01 andi Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -111,7 +111,7 @@ || ((int)T->str_offset.offset<0) || (T->str_offset.str->value.str.len <= T->str_offset.offset)) { zend_error(E_NOTICE, "Uninitialized string offset: %d", T->str_offset.offset); - T->tmp_var.value.str.val = empty_string; + T->tmp_var.value.str.val = STR_EMPTY_ALLOC(); T->tmp_var.value.str.len = 0; } else { char c = str->value.str.val[T->str_offset.offset]; http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.101&r2=1.102&ty=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.101 ZendEngine2/zend_object_handlers.c:1.102 --- ZendEngine2/zend_object_handlers.c:1.101 Wed Jul 14 05:04:13 2004 +++ ZendEngine2/zend_object_handlers.c Mon Jul 19 03:19:02 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.101 2004/07/14 09:04:13 stas Exp $ */ +/* $Id: zend_object_handlers.c,v 1.102 2004/07/19 07:19:02 andi Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -939,7 +939,7 @@ } } else { MAKE_STD_ZVAL(retval); - ZVAL_STRINGL(retval, empty_string, 0, 0); + ZVAL_STRINGL(retval, "", 0, 1); } *writeobj = *retval; zval_copy_ctor(writeobj); http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c?r1=1.193&r2=1.194&ty=u Index: ZendEngine2/zend_operators.c diff -u ZendEngine2/zend_operators.c:1.193 ZendEngine2/zend_operators.c:1.194 --- ZendEngine2/zend_operators.c:1.193 Mon May 10 10:56:21 2004 +++ ZendEngine2/zend_operators.c Mon Jul 19 03:19:02 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_operators.c,v 1.193 2004/05/10 14:56:21 zeev Exp $ */ +/* $Id: zend_operators.c,v 1.194 2004/07/19 07:19:02 andi Exp $ */ #include @@ -510,7 +510,7 @@ switch (op->type) { case IS_NULL: - op->value.str.val = empty_string; + op->value.str.val = STR_EMPTY_ALLOC(); op->value.str.len = 0; break; case IS_STRING: @@ -520,7 +520,7 @@ op->value.str.val = estrndup_rel("1", 1); op->value.str.len = 1; } else { - op->value.str.val = empty_string; + op->value.str.val = STR_EMPTY_ALLOC(); op->value.str.len = 0; } break; @@ -1130,11 +1130,8 @@ ZEND_API int add_string_to_string(zval *result, zval *op1, zval *op2) { int length = op1->value.str.len + op2->value.str.len; - if (op1->value.str.val == empty_string) { - result->value.str.val = (char *) emalloc(length+1); - } else { - result->value.str.val = (char *) erealloc(op1->value.str.val, length+1); - } + + result->value.str.val = (char *) erealloc(op1->value.str.val, length+1); memcpy(result->value.str.val+op1->value.str.len, op2->value.str.val, op2->value.str.len); result->value.str.val[length] = 0; result->value.str.len = length; @@ -1167,12 +1164,8 @@ if (result==op1) { /* special case, perform operations on result */ uint res_len = op1->value.str.len + op2->value.str.len; - if (result->value.str.len == 0) { /* handle empty_string */ - STR_FREE(result->value.str.val); - result->value.str.val = emalloc(res_len+1); - } else { - result->value.str.val = erealloc(result->value.str.val, res_len+1); - } + result->value.str.val = erealloc(result->value.str.val, res_len+1); + memcpy(result->value.str.val+result->value.str.len, op2->value.str.val, op2->value.str.len); result->value.str.val[res_len]=0; result->value.str.len = res_len; http://cvs.php.net/diff.php/ZendEngine2/zend_variables.c?r1=1.57&r2=1.58&ty=u Index: ZendEngine2/zend_variables.c diff -u ZendEngine2/zend_variables.c:1.57 ZendEngine2/zend_variables.c:1.58 --- ZendEngine2/zend_variables.c:1.57 Sat Jul 10 03:45:49 2004 +++ ZendEngine2/zend_variables.c Mon Jul 19 03:19:03 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_variables.c,v 1.57 2004/07/10 07:45:49 andi Exp $ */ +/* $Id: zend_variables.c,v 1.58 2004/07/19 07:19:03 andi Exp $ */ #include #include "zend.h" @@ -26,12 +26,6 @@ #include "zend_constants.h" #include "zend_list.h" -ZEND_API char *empty_string = ""; /* in order to save emalloc() and efree() time for - * empty strings (usually used to denote empty - * return values in failed functions). - * The macro STR_FREE() will not efree() it. - */ - ZEND_API void _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC) { @@ -86,9 +80,7 @@ case IS_STRING: case IS_CONSTANT: CHECK_ZVAL_STRING_REL(zvalue); - if (zvalue->value.str.val != empty_string) { - free(zvalue->value.str.val); - } + free(zvalue->value.str.val); break; case IS_ARRAY: case IS_CONSTANT_ARRAY: @@ -127,12 +119,6 @@ break; case IS_CONSTANT: case IS_STRING: - if (zvalue->value.str.val) { - if (zvalue->value.str.len==0) { - zvalue->value.str.val = empty_string; - return SUCCESS; - } - } CHECK_ZVAL_STRING_REL(zvalue); zvalue->value.str.val = (char *) estrndup_rel(zvalue->value.str.val, zvalue->value.str.len); break;