summaryrefslogtreecommitdiff
path: root/Zend/zend.h
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 /Zend/zend.h
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 'Zend/zend.h')
-rw-r--r--Zend/zend.h19
1 files changed, 8 insertions, 11 deletions
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))