summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend.c6
-rw-r--r--Zend/zend.h19
-rw-r--r--Zend/zend_API.h2
-rw-r--r--Zend/zend_alloc.h4
-rw-r--r--Zend/zend_execute.c2
-rw-r--r--Zend/zend_object_handlers.c2
-rw-r--r--Zend/zend_operators.c19
-rw-r--r--Zend/zend_variables.c16
-rw-r--r--ext/ereg/ereg.c8
-rw-r--r--ext/gd/gd.c6
-rw-r--r--ext/gd/gd_ctx.c2
-rw-r--r--ext/mbstring/php_mbregex.c2
-rw-r--r--ext/msql/php_msql.c6
-rw-r--r--ext/mssql/php_mssql.c6
-rw-r--r--ext/mysql/php_mysql.c6
-rw-r--r--ext/mysqli/mysqli_api.c4
-rw-r--r--ext/oci8/oci8.c4
-rw-r--r--ext/odbc/php_odbc.c8
-rw-r--r--ext/pcre/php_pcre.c9
-rw-r--r--ext/pgsql/pgsql.c4
-rw-r--r--ext/session/session.c9
-rw-r--r--ext/standard/file.c2
-rw-r--r--ext/standard/math.c6
-rw-r--r--ext/standard/reg.c8
-rw-r--r--ext/standard/string.c8
-rw-r--r--ext/standard/var_unserializer.c6
-rw-r--r--ext/standard/var_unserializer.re6
-rw-r--r--ext/sybase/php_sybase_db.c4
-rw-r--r--ext/sybase_ct/php_sybase_ct.c4
-rw-r--r--ext/wddx/wddx.c4
-rw-r--r--main/php_ini.c2
-rw-r--r--main/safe_mode.c4
-rw-r--r--sapi/apache/mod_php5.c2
-rw-r--r--sapi/apache2filter/php_functions.c4
-rw-r--r--sapi/apache2filter/sapi_apache2.c2
-rw-r--r--sapi/apache2handler/php_functions.c10
-rw-r--r--sapi/apache2handler/sapi_apache2.c2
-rw-r--r--sapi/apache_hooks/mod_php5.c2
38 files changed, 96 insertions, 124 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index 22af4592ae..a5c0e3ed69 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -194,7 +194,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
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 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
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 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
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;
}
}
diff --git a/Zend/zend.h b/Zend/zend.h
index c9b58779b5..d3ad270795 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -460,22 +460,19 @@ void zend_post_deactivate_modules(TSRMLS_D);
#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))
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 353b9385a4..313dd217ee 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -385,7 +385,7 @@ END_EXTERN_C()
#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; \
}
diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h
index 6e93d6abed..7521787ab8 100644
--- a/Zend/zend_alloc.h
+++ b/Zend/zend_alloc.h
@@ -119,8 +119,8 @@ ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZE
#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);
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index a958a1be60..4acdcf2c9b 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -111,7 +111,7 @@ static inline zval *_get_zval_ptr(znode *node, temp_variable *Ts, zval **should_
|| ((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];
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 7965bb0eb3..a1bfbe58f2 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -939,7 +939,7 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
}
} else {
MAKE_STD_ZVAL(retval);
- ZVAL_STRINGL(retval, empty_string, 0, 0);
+ ZVAL_STRINGL(retval, "", 0, 1);
}
*writeobj = *retval;
zval_copy_ctor(writeobj);
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 96217df5b1..8ef15ba102 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -510,7 +510,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC)
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 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC)
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_char_to_string(zval *result, zval *op1, zval *op2)
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 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
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;
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index e6fbd5342c..f147136a4d 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -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 @@ ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
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 @@ ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC)
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;
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c
index cf8e15cd95..02d1903539 100644
--- a/ext/ereg/ereg.c
+++ b/ext/ereg/ereg.c
@@ -428,7 +428,7 @@ static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
if (Z_STRVAL_PP(arg_pattern) && Z_STRLEN_PP(arg_pattern))
pattern = estrndup(Z_STRVAL_PP(arg_pattern), Z_STRLEN_PP(arg_pattern));
else
- pattern = empty_string;
+ pattern = STR_EMPTY_ALLOC();
} else {
convert_to_long_ex(arg_pattern);
pattern = emalloc(2);
@@ -440,7 +440,7 @@ static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
if (Z_STRVAL_PP(arg_replace) && Z_STRLEN_PP(arg_replace))
replace = estrndup(Z_STRVAL_PP(arg_replace), Z_STRLEN_PP(arg_replace));
else
- replace = empty_string;
+ replace = STR_EMPTY_ALLOC();
} else {
convert_to_long_ex(arg_replace);
replace = emalloc(2);
@@ -452,7 +452,7 @@ static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
if (Z_STRVAL_PP(arg_string) && Z_STRLEN_PP(arg_string))
string = estrndup(Z_STRVAL_PP(arg_string), Z_STRLEN_PP(arg_string));
else
- string = empty_string;
+ string = STR_EMPTY_ALLOC();
/* do the actual work */
ret = php_reg_replace(pattern, replace, string, icase, 1);
@@ -527,7 +527,7 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
while ((count == -1 || count > 1) && !(err = regexec(&re, strp, 1, subs, 0))) {
if (subs[0].rm_so == 0 && subs[0].rm_eo) {
/* match is at start of string, return empty string */
- add_next_index_stringl(return_value, empty_string, 0, 1);
+ add_next_index_stringl(return_value, "", 0, 1);
/* skip ahead the length of the regex match */
strp += subs[0].rm_eo;
} else if (subs[0].rm_so == 0 && subs[0].rm_eo == 0) {
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 9627d2cdf3..1476e5ee38 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -1709,7 +1709,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
}
if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) {
- if (!fn || fn == empty_string || php_check_open_basedir(fn TSRMLS_CC)) {
+ if (!fn || php_check_open_basedir(fn TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filename '%s'", fn);
RETURN_FALSE;
}
@@ -3825,13 +3825,13 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
}
/* Check origin file */
- if (!fn_org || fn_org == empty_string || php_check_open_basedir(fn_org TSRMLS_CC)) {
+ if (!fn_org || php_check_open_basedir(fn_org TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid origin filename '%s'", fn_org);
RETURN_FALSE;
}
/* Check destination file */
- if (!fn_dest || fn_dest == empty_string || php_check_open_basedir(fn_dest TSRMLS_CC)) {
+ if (!fn_dest || php_check_open_basedir(fn_dest TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid destination filename '%s'", fn_dest);
RETURN_FALSE;
}
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
index 6fb7b84ce4..b27ee45856 100644
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@ -82,7 +82,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
}
if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) {
- if (!fn || fn == empty_string || php_check_open_basedir(fn TSRMLS_CC)) {
+ if (!fn || php_check_open_basedir(fn TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filename '%s'", fn);
RETURN_FALSE;
}
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index b1543f2909..fdf9195b5f 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -864,7 +864,7 @@ PHP_FUNCTION(mb_split)
if (n > 0) {
add_next_index_stringl(return_value, pos, n, 1);
} else {
- add_next_index_stringl(return_value, empty_string, 0, 1);
+ add_next_index_stringl(return_value, "", 0, 1);
}
}
/* }}} */
diff --git a/ext/msql/php_msql.c b/ext/msql/php_msql.c
index f9a9e19feb..93522865b2 100644
--- a/ext/msql/php_msql.c
+++ b/ext/msql/php_msql.c
@@ -959,7 +959,7 @@ static void php_msql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
}
} else {
/*
- add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr, 1);
+ add_get_index_stringl(return_value, i, "", 0, (void **) &pval_ptr, 1);
*/
}
}
@@ -1097,8 +1097,8 @@ PHP_FUNCTION(msql_fetch_field)
}
object_init(return_value);
- add_property_string(return_value, "name",(msql_field->name?msql_field->name:empty_string), 1);
- add_property_string(return_value, "table",(msql_field->table?msql_field->table:empty_string), 1);
+ add_property_string(return_value, "name",(msql_field->name?msql_field->name:""), 1);
+ add_property_string(return_value, "table",(msql_field->table?msql_field->table:""), 1);
add_property_long(return_value, "not_null",IS_NOT_NULL(msql_field->flags));
#if MSQL1
add_property_long(return_value, "primary_key",(msql_field->flags&PRI_KEY_FLAG?1:0));
diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c
index 9930d3d0e4..9f8dd183b3 100644
--- a/ext/mssql/php_mssql.c
+++ b/ext/mssql/php_mssql.c
@@ -333,7 +333,7 @@ PHP_RINIT_FUNCTION(mssql)
MS_SQL_G(default_link) = -1;
MS_SQL_G(num_links) = MS_SQL_G(num_persistent);
MS_SQL_G(appname) = estrndup("PHP 5", 5);
- MS_SQL_G(server_message) = empty_string;
+ MS_SQL_G(server_message) = NULL;
MS_SQL_G(min_error_severity) = MS_SQL_G(cfg_min_error_severity);
MS_SQL_G(min_message_severity) = MS_SQL_G(cfg_min_message_severity);
if (MS_SQL_G(connect_timeout) < 1) MS_SQL_G(connect_timeout) = 1;
@@ -1045,7 +1045,7 @@ static int _mssql_fetch_batch(mssql_link *mssql_ptr, mssql_result *result, int r
result->fields[i].column_source = estrdup(source);
}
else {
- result->fields[i].column_source = empty_string;
+ result->fields[i].column_source = STR_EMPTY_ALLOC();
}
column_types[i] = coltype(i+1);
@@ -1267,7 +1267,7 @@ PHP_FUNCTION(mssql_get_last_message)
RETURN_STRING(MS_SQL_G(server_message),1);
}
else {
- RETURN_STRING(empty_string,1);
+ RETURN_STRING("",1);
}
}
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 11dae41632..f8da8c8ea5 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -2245,9 +2245,9 @@ PHP_FUNCTION(mysql_fetch_field)
}
object_init(return_value);
- add_property_string(return_value, "name",(mysql_field->name?mysql_field->name:empty_string), 1);
- add_property_string(return_value, "table",(mysql_field->table?mysql_field->table:empty_string), 1);
- add_property_string(return_value, "def",(mysql_field->def?mysql_field->def:empty_string), 1);
+ add_property_string(return_value, "name",(mysql_field->name?mysql_field->name:""), 1);
+ add_property_string(return_value, "table",(mysql_field->table?mysql_field->table:""), 1);
+ add_property_string(return_value, "def",(mysql_field->def?mysql_field->def:""), 1);
add_property_long(return_value, "max_length", mysql_field->max_length);
add_property_long(return_value, "not_null", IS_NOT_NULL(mysql_field->flags)?1:0);
add_property_long(return_value, "primary_key", IS_PRI_KEY(mysql_field->flags)?1:0);
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index b6dbc0efc0..4f6a80ad05 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -906,7 +906,7 @@ PHP_FUNCTION(mysqli_get_host_info)
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
- RETURN_STRING((mysql->mysql->host_info) ? mysql->mysql->host_info : empty_string, 1);
+ RETURN_STRING((mysql->mysql->host_info) ? mysql->mysql->host_info : "", 1);
}
/* }}} */
@@ -971,7 +971,7 @@ PHP_FUNCTION(mysqli_info)
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
- RETURN_STRING((mysql->mysql->info) ? mysql->mysql->info : empty_string, 1);
+ RETURN_STRING((mysql->mysql->info) ? mysql->mysql->info : "", 1);
}
/* }}} */
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index 597b177a49..3f46fb4e33 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -880,12 +880,12 @@ static int _oci_bind_post_exec(void *data TSRMLS_DC)
if (bind->indicator == -1) { /* NULL */
zval *val = bind->zval;
- if (Z_TYPE_P(val) == IS_STRING && (Z_STRVAL_P(val) != empty_string)) {
+ if (Z_TYPE_P(val) == IS_STRING)) {
*Z_STRVAL_P(val) = '\0'; /* XXX avoid warning in debug mode */
}
zval_dtor(val);
ZVAL_NULL(val);
- } else if (Z_TYPE_P(bind->zval) == IS_STRING && (Z_STRVAL_P(bind->zval) != empty_string)) {
+ } else if (Z_TYPE_P(bind->zval) == IS_STRING) {
Z_STRVAL_P(bind->zval) = erealloc(Z_STRVAL_P(bind->zval), Z_STRLEN_P(bind->zval)+1);
Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] = '\0';
}
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 0908ce6a5b..7e98b1cf05 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -1421,13 +1421,13 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
if (result->binmode <= 0) {
- Z_STRVAL_P(tmp) = empty_string;
+ Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
break;
}
if (result->binmode == 1) sql_c_type = SQL_C_BINARY;
case SQL_LONGVARCHAR:
if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) {
- Z_STRVAL_P(tmp) = empty_string;
+ Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
break;
}
if (buf == NULL) buf = emalloc(result->longreadlen + 1);
@@ -1580,13 +1580,13 @@ PHP_FUNCTION(odbc_fetch_into)
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
if (result->binmode <= 0) {
- Z_STRVAL_P(tmp) = empty_string;
+ Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
break;
}
if (result->binmode == 1) sql_c_type = SQL_C_BINARY;
case SQL_LONGVARCHAR:
if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) {
- Z_STRVAL_P(tmp) = empty_string;
+ Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
break;
}
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index f489291ccb..52ceb6f727 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -511,7 +511,7 @@ static void php_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global)
*/
if (count < num_subpats) {
for (; i < num_subpats; i++) {
- add_next_index_string(match_sets[i], empty_string, 1);
+ add_next_index_string(match_sets[i], "", 1);
}
}
} else {
@@ -734,7 +734,7 @@ static int preg_do_eval(char *eval_str, int eval_str_len, char *subject,
esc_match_len = 0;
}
} else {
- esc_match = empty_string;
+ esc_match = "";
esc_match_len = 0;
match_len = 0;
}
@@ -1005,7 +1005,8 @@ static char *php_replace_in_subject(zval *regex, zval *replace, zval **subject,
/* Make sure we're dealing with strings. */
convert_to_string_ex(subject);
- ZVAL_STRINGL(&empty_replace, empty_string, 0, 0);
+ /* FIXME: This might need to be changed to STR_EMPTY_ALLOC(). Check if this zval could be dtor()'ed somehow */
+ ZVAL_STRINGL(&empty_replace, "", 0, 0);
/* If regex is an array */
if (Z_TYPE_P(regex) == IS_ARRAY) {
@@ -1389,7 +1390,7 @@ PHP_FUNCTION(preg_quote)
/* Nothing to do if we got an empty string */
if (in_str == in_str_end) {
- RETVAL_STRINGL(empty_string, 0, 0);
+ RETVAL_STRINGL("", 0, 1);
}
if (ZEND_NUM_ARGS() == 2) {
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 414e2050ec..786be839fc 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -1214,7 +1214,7 @@ static char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list TSRMLS_DC)
PQclear(result);
}
smart_str_free(&str);
- return empty_string;
+ return STR_EMPTY_ALLOC();
}
num_rows = PQntuples(result);
oid_offset = PQfnumber(result,"oid");
@@ -1786,7 +1786,7 @@ PHP_FUNCTION(pg_last_oid)
if (Z_STRVAL_P(return_value)) {
RETURN_STRING(Z_STRVAL_P(return_value), 1);
}
- RETURN_STRING(empty_string, 0);
+ RETURN_STRING("", 1);
#endif
}
/* }}} */
diff --git a/ext/session/session.c b/ext/session/session.c
index 135a732253..f5efc8ba9d 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -1060,7 +1060,7 @@ static void php_session_reset_id(TSRMLS_D)
smart_str_0(&var);
REGISTER_STRINGL_CONSTANT("SID", var.c, var.len, 0);
} else {
- REGISTER_STRINGL_CONSTANT("SID", empty_string, 0, 0);
+ REGISTER_STRINGL_CONSTANT("SID", "", 0, 1);
}
if (PS(apply_trans_sid)) {
@@ -1370,13 +1370,16 @@ PHP_FUNCTION(session_id)
{
zval **p_name;
int ac = ZEND_NUM_ARGS();
- char *old = empty_string;
+ char *old;
if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &p_name) == FAILURE)
WRONG_PARAM_COUNT;
- if (PS(id))
+ if (PS(id)) {
old = estrdup(PS(id));
+ } else {
+ old = STR_EMPTY_ALLOC();
+ }
if (ac == 1) {
convert_to_string_ex(p_name);
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 6041fa4249..b3af5a20c0 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -416,7 +416,7 @@ PHP_FUNCTION(get_meta_tags)
if (have_content) {
add_assoc_string(return_value, name, value, 0);
} else {
- add_assoc_string(return_value, name, empty_string, 0);
+ add_assoc_string(return_value, name, "", 0);
}
efree(name);
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 1ab898569b..8a2b3ecec1 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -791,7 +791,7 @@ _php_math_longtobase(zval *arg, int base)
unsigned long value;
if (Z_TYPE_P(arg) != IS_LONG || base < 2 || base > 36) {
- return empty_string;
+ return STR_EMPTY_ALLOC();
}
value = Z_LVAL_P(arg);
@@ -820,7 +820,7 @@ _php_math_zvaltobase(zval *arg, int base TSRMLS_DC)
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
if ((Z_TYPE_P(arg) != IS_LONG && Z_TYPE_P(arg) != IS_DOUBLE) || base < 2 || base > 36) {
- return empty_string;
+ return STR_EMPTY_ALLOC();
}
if (Z_TYPE_P(arg) == IS_DOUBLE) {
@@ -831,7 +831,7 @@ _php_math_zvaltobase(zval *arg, int base TSRMLS_DC)
/* Don't try to convert +/- infinity */
if (fvalue == HUGE_VAL || fvalue == -HUGE_VAL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number too large");
- return empty_string;
+ return STR_EMPTY_ALLOC();
}
end = ptr = buf + sizeof(buf) - 1;
diff --git a/ext/standard/reg.c b/ext/standard/reg.c
index cf8e15cd95..02d1903539 100644
--- a/ext/standard/reg.c
+++ b/ext/standard/reg.c
@@ -428,7 +428,7 @@ static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
if (Z_STRVAL_PP(arg_pattern) && Z_STRLEN_PP(arg_pattern))
pattern = estrndup(Z_STRVAL_PP(arg_pattern), Z_STRLEN_PP(arg_pattern));
else
- pattern = empty_string;
+ pattern = STR_EMPTY_ALLOC();
} else {
convert_to_long_ex(arg_pattern);
pattern = emalloc(2);
@@ -440,7 +440,7 @@ static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
if (Z_STRVAL_PP(arg_replace) && Z_STRLEN_PP(arg_replace))
replace = estrndup(Z_STRVAL_PP(arg_replace), Z_STRLEN_PP(arg_replace));
else
- replace = empty_string;
+ replace = STR_EMPTY_ALLOC();
} else {
convert_to_long_ex(arg_replace);
replace = emalloc(2);
@@ -452,7 +452,7 @@ static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
if (Z_STRVAL_PP(arg_string) && Z_STRLEN_PP(arg_string))
string = estrndup(Z_STRVAL_PP(arg_string), Z_STRLEN_PP(arg_string));
else
- string = empty_string;
+ string = STR_EMPTY_ALLOC();
/* do the actual work */
ret = php_reg_replace(pattern, replace, string, icase, 1);
@@ -527,7 +527,7 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
while ((count == -1 || count > 1) && !(err = regexec(&re, strp, 1, subs, 0))) {
if (subs[0].rm_so == 0 && subs[0].rm_eo) {
/* match is at start of string, return empty string */
- add_next_index_stringl(return_value, empty_string, 0, 1);
+ add_next_index_stringl(return_value, "", 0, 1);
/* skip ahead the length of the regex match */
strp += subs[0].rm_eo;
} else if (subs[0].rm_so == 0 && subs[0].rm_eo == 0) {
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 7a7020b852..3eb4e8f707 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -3206,7 +3206,7 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval **subje
convert_to_string_ex(subject);
Z_TYPE_P(result) = IS_STRING;
if (Z_STRLEN_PP(subject) == 0) {
- ZVAL_STRINGL(result, empty_string, 0, 1);
+ ZVAL_STRINGL(result, "", 0, 1);
return;
}
@@ -3254,7 +3254,7 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval **subje
zend_hash_move_forward(Z_ARRVAL_P(replace));
} else {
/* We've run out of replacement strings, so use an empty one. */
- replace_value = empty_string;
+ replace_value = "";
replace_len = 0;
}
}
@@ -4186,11 +4186,11 @@ PHP_FUNCTION(str_repeat)
/* Don't waste our time if it's empty */
if (Z_STRLEN_PP(input_str) == 0)
- RETURN_STRINGL(empty_string, 0, 1);
+ RETURN_STRINGL("", 0, 1);
/* ... or if the multiplier is zero */
if (Z_LVAL_PP(mult) == 0)
- RETURN_STRINGL(empty_string, 0, 1);
+ RETURN_STRINGL("", 0, 1);
/* Initialize the result string */
result_len = Z_STRLEN_PP(input_str) * Z_LVAL_PP(mult);
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index 261c1fc791..649661bcae 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -605,11 +605,7 @@ yy44:
len = parse_iv(start + 2);
- if (len == 0) {
- str = empty_string;
- } else {
- str = estrndup(YYCURSOR, len);
- }
+ str = estrndup(YYCURSOR, len);
YYCURSOR += len + 2;
*p = YYCURSOR;
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index 6ae7424b77..e42af889f8 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -350,11 +350,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
len = parse_iv(start + 2);
- if (len == 0) {
- str = empty_string;
- } else {
- str = estrndup(YYCURSOR, len);
- }
+ str = estrndup(YYCURSOR, len);
YYCURSOR += len + 2;
*p = YYCURSOR;
diff --git a/ext/sybase/php_sybase_db.c b/ext/sybase/php_sybase_db.c
index f2c98c7640..a6f0886f86 100644
--- a/ext/sybase/php_sybase_db.c
+++ b/ext/sybase/php_sybase_db.c
@@ -282,7 +282,7 @@ PHP_RINIT_FUNCTION(sybase)
php_sybase_module.default_link=-1;
php_sybase_module.num_links = php_sybase_module.num_persistent;
php_sybase_module.appname = estrndup("PHP " PHP_VERSION, sizeof("PHP " PHP_VERSION));
- php_sybase_module.server_message = empty_string;
+ php_sybase_module.server_message = STR_EMPTY_ALLOC();
php_sybase_module.min_error_severity = php_sybase_module.cfg_min_error_severity;
php_sybase_module.min_message_severity = php_sybase_module.cfg_min_message_severity;
return SUCCESS;
@@ -886,7 +886,7 @@ PHP_FUNCTION(sybase_query)
result->fields[i].max_length = dbcollen(sybase_ptr->link,i+1);
result->fields[i].column_source = estrdup(dbcolsource(sybase_ptr->link,i+1));
if (!result->fields[i].column_source) {
- result->fields[i].column_source = empty_string;
+ result->fields[i].column_source = STR_EMPTY_ALLOC();
}
Z_TYPE(result->fields[i]) = column_types[i];
/* set numeric flag */
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c
index 43dca5df2a..a7593685be 100644
--- a/ext/sybase_ct/php_sybase_ct.c
+++ b/ext/sybase_ct/php_sybase_ct.c
@@ -428,7 +428,7 @@ PHP_RINIT_FUNCTION(sybase)
SybCtG(default_link)=-1;
SybCtG(num_links) = SybCtG(num_persistent);
SybCtG(appname) = estrndup("PHP " PHP_VERSION, sizeof("PHP " PHP_VERSION));
- SybCtG(server_message) = empty_string;
+ SybCtG(server_message) = STR_EMPTY_ALLOC();
return SUCCESS;
}
@@ -1274,7 +1274,7 @@ static sybase_result * php_sybase_fetch_result_set (sybase_link *sybase_ptr, int
result->fields[i].name = estrdup(computed_buf);
j++;
}
- result->fields[i].column_source = empty_string;
+ result->fields[i].column_source = STR_EMPTY_ALLOC();
result->fields[i].max_length = result->datafmt[i].maxlength-1;
result->fields[i].numeric = result->numerics[i];
Z_TYPE(result->fields[i]) = result->types[i];
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 33dbfbd9fd..59c5188505 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -710,7 +710,7 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
ALLOC_ZVAL(ent.data);
INIT_PZVAL(ent.data);
Z_TYPE_P(ent.data) = IS_STRING;
- Z_STRVAL_P(ent.data) = empty_string;
+ Z_STRVAL_P(ent.data) = STR_EMPTY_ALLOC();
Z_STRLEN_P(ent.data) = 0;
wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
} else if (!strcmp(name, EL_BINARY)) {
@@ -720,7 +720,7 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
ALLOC_ZVAL(ent.data);
INIT_PZVAL(ent.data);
Z_TYPE_P(ent.data) = IS_STRING;
- Z_STRVAL_P(ent.data) = empty_string;
+ Z_STRVAL_P(ent.data) = STR_EMPTY_ALLOC();
Z_STRLEN_P(ent.data) = 0;
wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
} else if (!strcmp(name, EL_CHAR)) {
diff --git a/main/php_ini.c b/main/php_ini.c
index 5fb95c71d8..35542ef63d 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -170,7 +170,7 @@ PHPAPI void display_ini_entries(zend_module_entry *module)
*/
static void pvalue_config_destructor(zval *pvalue)
{
- if (Z_TYPE_P(pvalue) == IS_STRING && Z_STRVAL_P(pvalue) != empty_string) {
+ if (Z_TYPE_P(pvalue) == IS_STRING) {
free(Z_STRVAL_P(pvalue));
}
}
diff --git a/main/safe_mode.c b/main/safe_mode.c
index 9271610f9b..0412433b22 100644
--- a/main/safe_mode.c
+++ b/main/safe_mode.c
@@ -207,11 +207,11 @@ PHPAPI char *php_get_current_user()
pstat = sapi_get_stat(TSRMLS_C);
if (!pstat) {
- return empty_string;
+ return "";
}
if ((pwd=getpwuid(pstat->st_uid))==NULL) {
- return empty_string;
+ return "";
}
SG(request_info).current_user_length = strlen(pwd->pw_name);
SG(request_info).current_user = estrndup(pwd->pw_name, SG(request_info).current_user_length);
diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c
index 4aac2d2862..083cc8be56 100644
--- a/sapi/apache/mod_php5.c
+++ b/sapi/apache/mod_php5.c
@@ -235,7 +235,7 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_
if (elts[i].val) {
val = elts[i].val;
} else {
- val = empty_string;
+ val = "";
}
php_register_variable(elts[i].key, val, track_vars_array TSRMLS_CC);
}
diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c
index 5e160ce47a..b3ac9c2c09 100644
--- a/sapi/apache2filter/php_functions.c
+++ b/sapi/apache2filter/php_functions.c
@@ -165,7 +165,7 @@ PHP_FUNCTION(apache_request_headers)
arr = apr_table_elts(ctx->f->r->headers_in);
APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) val = empty_string;
+ if (!val) val = "";
add_assoc_string(return_value, key, val, 1);
APR_ARRAY_FOREACH_CLOSE()
}
@@ -185,7 +185,7 @@ PHP_FUNCTION(apache_response_headers)
arr = apr_table_elts(ctx->f->r->headers_out);
APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) val = empty_string;
+ if (!val) val = "";
add_assoc_string(return_value, key, val, 1);
APR_ARRAY_FOREACH_CLOSE()
}
diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c
index d9eee97493..cf6bec1933 100644
--- a/sapi/apache2filter/sapi_apache2.c
+++ b/sapi/apache2filter/sapi_apache2.c
@@ -220,7 +220,7 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
char *key, *val;
APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) val = empty_string;
+ if (!val) val = "";
php_register_variable(key, val, track_vars_array TSRMLS_CC);
APR_ARRAY_FOREACH_CLOSE()
diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c
index eeba18a691..fca55d9c33 100644
--- a/sapi/apache2handler/php_functions.c
+++ b/sapi/apache2handler/php_functions.c
@@ -183,7 +183,7 @@ PHP_FUNCTION(apache_request_headers)
arr = apr_table_elts(ctx->r->headers_in);
APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) val = empty_string;
+ if (!val) val = "";
add_assoc_string(return_value, key, val, 1);
APR_ARRAY_FOREACH_CLOSE()
}
@@ -203,7 +203,7 @@ PHP_FUNCTION(apache_response_headers)
arr = apr_table_elts(ctx->r->headers_out);
APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) val = empty_string;
+ if (!val) val = "";
add_assoc_string(return_value, key, val, 1);
APR_ARRAY_FOREACH_CLOSE()
}
@@ -423,7 +423,7 @@ PHP_MINFO_FUNCTION(apache)
php_info_print_table_header(2, "Variable", "Value");
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) {
- val = empty_string;
+ val = "";
}
php_info_print_table_row(2, key, val);
APR_ARRAY_FOREACH_CLOSE()
@@ -438,7 +438,7 @@ PHP_MINFO_FUNCTION(apache)
arr = apr_table_elts(((php_struct *) SG(server_context))->r->headers_in);
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) {
- val = empty_string;
+ val = "";
}
php_info_print_table_row(2, key, val);
APR_ARRAY_FOREACH_CLOSE()
@@ -447,7 +447,7 @@ PHP_MINFO_FUNCTION(apache)
arr = apr_table_elts(((php_struct *) SG(server_context))->r->headers_out);
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) {
- val = empty_string;
+ val = "";
}
php_info_print_table_row(2, key, val);
APR_ARRAY_FOREACH_CLOSE()
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c
index f5b133bcc1..e7e9571044 100644
--- a/sapi/apache2handler/sapi_apache2.c
+++ b/sapi/apache2handler/sapi_apache2.c
@@ -215,7 +215,7 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
char *key, *val;
APR_ARRAY_FOREACH_OPEN(arr, key, val)
- if (!val) val = empty_string;
+ if (!val) val = "";
php_register_variable(key, val, track_vars_array TSRMLS_CC);
APR_ARRAY_FOREACH_CLOSE()
diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c
index 516a465c2b..53beeb0943 100644
--- a/sapi/apache_hooks/mod_php5.c
+++ b/sapi/apache_hooks/mod_php5.c
@@ -382,7 +382,7 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_
if (elts[i].val) {
val = elts[i].val;
} else {
- val = empty_string;
+ val = "";
}
php_register_variable(elts[i].key, val, track_vars_array TSRMLS_CC);
}