compiler_globals->script_encoding_list = NULL;
#ifdef ZTS
- compiler_globals->empty_string = zend_string_alloc(sizeof("")-1, 1);
- compiler_globals->empty_string->val[0] = '\000';
- zend_string_hash_val(compiler_globals->empty_string);
- compiler_globals->empty_string->gc.u.v.flags |= IS_STR_INTERNED;
+ zend_interned_empty_string_init(&compiler_globals->empty_string TSRMLS_CC);
memset(compiler_globals->one_char_string, 0, sizeof(compiler_globals->one_char_string));
#endif
compiler_globals->last_static_member = 0;
#ifdef ZTS
- if (NULL != compiler_globals->empty_string) {
- free(compiler_globals->empty_string);
- compiler_globals->empty_string = NULL;
- }
+ zend_interned_empty_string_free(&compiler_globals->empty_string TSRMLS_CC);
#endif
}
/* }}} */
void zend_interned_strings_init(TSRMLS_D)
{
+#ifndef ZTS
zend_string *str;
-#ifndef ZTS
zend_hash_init(&CG(interned_strings), 1024, NULL, _str_dtor, 1);
CG(interned_strings).nTableMask = CG(interned_strings).nTableSize - 1;
str = zend_string_alloc(sizeof("")-1, 1);
str->val[0] = '\000';
CG(empty_string) = zend_new_interned_string_int(str TSRMLS_CC);
-#else
- str = zend_string_alloc(sizeof("")-1, 1);
- str->val[0] = '\000';
- zend_string_hash_val(str);
- str->gc.u.v.flags |= IS_STR_INTERNED;
- CG(empty_string) = str;
#endif
/* one char strings (the actual interned strings are going to be created by ext/opcache) */
{
#ifndef ZTS
zend_hash_destroy(&CG(interned_strings));
-#else
- if (NULL != CG(empty_string)) {
- free(CG(empty_string));
- CG(empty_string) = NULL;
- }
#endif
}
return hash;
}
+static zend_always_inline void zend_interned_empty_string_init(zend_string **s TSRMLS_DC)
+{
+ zend_string *str;
+
+ str = zend_string_alloc(sizeof("")-1, 1);
+ str->val[0] = '\000';
+
+#ifndef ZTS
+ *s = zend_new_interned_string(str TSRMLS_CC);
+#else
+ zend_string_hash_val(str);
+ str->gc.u.v.flags |= IS_STR_INTERNED;
+ *s = str;
+#endif
+}
+
+static zend_always_inline void zend_interned_empty_string_free(zend_string **s TSRMLS_DC)
+{
+ if (NULL != *s) {
+ free(*s);
+ *s = NULL;
+ }
+}
+
#endif /* ZEND_STRING_H */
/*