diff options
author | Andi Gutmans <andi@php.net> | 2004-07-19 07:19:50 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2004-07-19 07:19:50 +0000 |
commit | 56f8195fe592e79d90c78fb015f39bffa7f39422 (patch) | |
tree | 6a1bf69bc9cd23fab98c4d3d6c12368b56d26079 /ext/pcre/php_pcre.c | |
parent | 599ae4b1b53d46e10447dab8fb4faa2d0517370a (diff) | |
download | php-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/pcre/php_pcre.c')
-rw-r--r-- | ext/pcre/php_pcre.c | 9 |
1 files changed, 5 insertions, 4 deletions
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) { |