summaryrefslogtreecommitdiff
path: root/ext/ereg
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2004-07-19 07:19:50 +0000
committerAndi Gutmans <andi@php.net>2004-07-19 07:19:50 +0000
commit56f8195fe592e79d90c78fb015f39bffa7f39422 (patch)
tree6a1bf69bc9cd23fab98c4d3d6c12368b56d26079 /ext/ereg
parent599ae4b1b53d46e10447dab8fb4faa2d0517370a (diff)
downloadphp-git-56f8195fe592e79d90c78fb015f39bffa7f39422.tar.gz
- Nuke empty_string. It is a reminanent from the time where RETURN_FALSE()
used to return "" and not bool(false). It's not worth keeping it because STR_FREE() and zval_dtor() always have to check for it and it slows down the general case. In addition, it seems that empty_string has been abused quite a lot, and was used not only for setting zval's but generally in PHP code instead of "", which wasn't the intention. Last but not least, nuking empty_string should improve stability as I doubt every place correctly checked if they are not mistakenly erealloc()'ing it or calling efree() on it. NOTE: Some code is probably broken. Each extension maintainer should check and see that my changes are OK. Also, I haven't had time to touch PECL yet. Will try and do it tomorrow.
Diffstat (limited to 'ext/ereg')
-rw-r--r--ext/ereg/ereg.c8
1 files changed, 4 insertions, 4 deletions
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) {