}
/* }}} */
+static int zend_startup_module_zval(zval *zv TSRMLS_DC) /* {{{ */
+{
+ zend_module_entry *module = Z_PTR_P(zv);
+
+ return zend_startup_module_ex(module TSRMLS_CC);
+}
+/* }}} */
+
+
static void zend_sort_modules(void *base, size_t count, size_t siz, compare_func_t compare TSRMLS_DC) /* {{{ */
{
Bucket *b1 = base;
int startup_count = 0;
int shutdown_count = 0;
int post_deactivate_count = 0;
- zend_class_entry **pce;
+ zend_class_entry *ce;
int class_count = 0;
/* Collect extensions with request startup/shutdown handlers */
/* Collect internal classes with static members */
for (zend_hash_internal_pointer_reset_ex(CG(class_table), &pos);
- (pce = zend_hash_get_current_data_ptr_ex(CG(class_table), &pos)) != NULL;
+ (ce = zend_hash_get_current_data_ptr_ex(CG(class_table), &pos)) != NULL;
zend_hash_move_forward_ex(CG(class_table), &pos)) {
- if ((*pce)->type == ZEND_INTERNAL_CLASS &&
- (*pce)->default_static_members_count > 0) {
+ if (ce->type == ZEND_INTERNAL_CLASS &&
+ ce->default_static_members_count > 0) {
class_count++;
}
}
if (class_count) {
for (zend_hash_internal_pointer_reset_ex(CG(class_table), &pos);
- (pce = zend_hash_get_current_data_ptr_ex(CG(class_table), &pos)) != NULL;
+ (ce = zend_hash_get_current_data_ptr_ex(CG(class_table), &pos)) != NULL;
zend_hash_move_forward_ex(CG(class_table), &pos)) {
- if ((*pce)->type == ZEND_INTERNAL_CLASS &&
- (*pce)->default_static_members_count > 0) {
- class_cleanup_handlers[--class_count] = *pce;
+ if (ce->type == ZEND_INTERNAL_CLASS &&
+ ce->default_static_members_count > 0) {
+ class_cleanup_handlers[--class_count] = ce;
}
}
}
ZEND_API int zend_startup_modules(TSRMLS_D) /* {{{ */
{
zend_hash_sort(&module_registry, zend_sort_modules, NULL, 0 TSRMLS_CC);
- zend_hash_apply(&module_registry, (apply_func_t)zend_startup_module_ex TSRMLS_CC);
+ zend_hash_apply(&module_registry, zend_startup_module_zval TSRMLS_CC);
return SUCCESS;
}
/* }}} */
if (scope) {
class_name_len = scope->name->len;
- if ((lc_class_name = zend_memrchr(scope->name, '\\', class_name_len))) {
+ if ((lc_class_name = zend_memrchr(scope->name->val, '\\', class_name_len))) {
++lc_class_name;
class_name_len -= (lc_class_name - scope->name->val);
lc_class_name = zend_str_tolower_dup(lc_class_name, class_name_len);
#define CHECK_NULL_PATH(p, l) (strlen(p) != l)
#define ZVAL_STRINGL(z, s, l) do { \
- zval *__z = (z); \
+ zval *_z = (z); \
int __l = l; \
- ZVAL_STR(__z, STR_ALLOC(__l, 0)); \
- memcpy(Z_STRVAL_P(__z), (s), __l + 1); \
+ ZVAL_STR(_z, STR_ALLOC(__l, 0)); \
+ memcpy(Z_STRVAL_P(_z), (s), __l + 1); \
} while (0)
#define ZVAL_STRING(z, s) do { \
} while (0)
#define ZVAL_PSTRINGL(z, s, l) do { \
- zval *__z = (z); \
+ zval *_z = (z); \
int __l = l; \
- ZVAL_STR(__z, STR_ALLOC(__l, 1)); \
- memcpy(Z_STRVAL_P(__z), (s), __l + 1); \
+ ZVAL_STR(_z, STR_ALLOC(__l, 1)); \
+ memcpy(Z_STRVAL_P(_z), (s), __l + 1); \
} while (0)
#define ZVAL_PSTRING(z, s) do { \
} while (0)
#define ZVAL_EMPTY_PSTRING(z) do { \
- ZVAL_PSTRINGL(z, "", 0); \
+ ZVAL_PSTRINGL(z, "", 0); \
} while (0)
#define ZVAL_ZVAL(z, zv, copy, dtor) do { \
}
/* }}} */
+static void zend_duplicate_property_info_zval(zval *zv) /* {{{ */
+{
+ zend_duplicate_property_info((zend_property_info*)Z_PTR_P(zv));
+}
+/* }}} */
+
static void zend_duplicate_property_info_internal(zend_property_info *property_info) /* {{{ */
{
STR_ADDREF(property_info->name);
}
/* }}} */
-static void zend_destroy_property_info(zend_property_info *property_info) /* {{{ */
+static void zend_duplicate_property_info_internal_zval(zval *zv) /* {{{ */
+{
+ zend_duplicate_property_info_internal((zend_property_info*)Z_PTR_P(zv));
+}
+/* }}} */
+
+static void zend_destroy_property_info(zval *zv) /* {{{ */
{
+ zend_property_info *property_info = Z_PTR_P(zv);
+
STR_RELEASE(property_info->name);
if (property_info->doc_comment) {
STR_RELEASE(property_info->doc_comment);
}
/* }}} */
-static void zend_destroy_property_info_internal(zend_property_info *property_info) /* {{{ */
+static void zend_destroy_property_info_internal(zval *zv) /* {{{ */
{
+ zend_property_info *property_info = Z_PTR_P(zv);
+
STR_RELEASE(property_info->name);
}
/* }}} */
}
/* }}} */
-static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_function *parent, const zend_hash_key *hash_key, zend_class_entry *child_ce) /* {{{ */
+static zend_bool do_inherit_method_check(HashTable *child_function_table, zval *zv, const zend_hash_key *hash_key, zend_class_entry *child_ce) /* {{{ */
{
+ zend_function *parent = Z_PTR_P(zv);
zend_uint parent_flags = parent->common.fn_flags;
zend_function *child;
TSRMLS_FETCH();
}
/* }}} */
-static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_property_info *parent_info, const zend_hash_key *hash_key, zend_class_entry *ce) /* {{{ */
+static zend_bool do_inherit_property_access_check(HashTable *target_ht, zval *zv, const zend_hash_key *hash_key, zend_class_entry *ce) /* {{{ */
{
+ zend_property_info *parent_info = Z_PTR_P(zv);
zend_property_info *child_info;
zend_class_entry *parent_ce = ce->parent;
if (parent_ce->default_properties_count) {
int i = ce->default_properties_count + parent_ce->default_properties_count;
- ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(void*) * i, ce->type == ZEND_INTERNAL_CLASS);
+ ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(zval) * i, ce->type == ZEND_INTERNAL_CLASS);
if (ce->default_properties_count) {
while (i-- > parent_ce->default_properties_count) {
ce->default_properties_table[i] = ce->default_properties_table[i - parent_ce->default_properties_count];
}
}
for (i = 0; i < parent_ce->default_properties_count; i++) {
- ce->default_properties_table[i] = parent_ce->default_properties_table[i];
- if (Z_TYPE(ce->default_properties_table[i]) != IS_UNDEF) {
+ ZVAL_COPY_VALUE(&ce->default_properties_table[i], &parent_ce->default_properties_table[i]);
+ if (IS_REFCOUNTED(Z_TYPE(ce->default_properties_table[i]))) {
#ifdef ZTS
if (parent_ce->type != ce->type) {
zval *p;
}
}
- zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (copy_ctor_func_t) (ce->type & ZEND_INTERNAL_CLASS ? zend_duplicate_property_info_internal : zend_duplicate_property_info), (merge_checker_func_t) do_inherit_property_access_check, ce);
+ zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (ce->type & ZEND_INTERNAL_CLASS ? zend_duplicate_property_info_internal_zval : zend_duplicate_property_info_zval), (merge_checker_func_t) do_inherit_property_access_check, ce);
zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, zval_property_ctor(parent_ce, ce), 0);
zend_hash_merge_ex(&ce->function_table, &parent_ce->function_table, (copy_ctor_func_t) do_inherit_method, (merge_checker_func_t) do_inherit_method_check, ce);
ce->default_properties_table = NULL;
ce->default_static_members_table = NULL;
- zend_hash_init_ex(&ce->properties_info, 0, NULL, (dtor_func_t) (persistent_hashes ? zend_destroy_property_info_internal : zend_destroy_property_info), persistent_hashes, 0);
+ zend_hash_init_ex(&ce->properties_info, 0, NULL, (persistent_hashes ? zend_destroy_property_info_internal : zend_destroy_property_info), persistent_hashes, 0);
zend_hash_init_ex(&ce->constants_table, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0);
zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0);
ZEND_API int zend_get_constant(const char *name, uint name_len, zval *result TSRMLS_DC)
{
zend_constant *c;
- int retval = 1;
if ((c = zend_hash_str_find_ptr(EG(zend_constants), name, name_len)) == NULL) {
char *lcname = zend_str_tolower_dup(name, name_len);
if ((c = zend_hash_str_find_ptr(EG(zend_constants), lcname, name_len)) != NULL) {
if (c->flags & CONST_CS) {
- retval=0;
+ c = NULL;
}
} else {
c = zend_get_special_constant(name, name_len TSRMLS_CC);
efree(lcname);
}
- if (retval) {
+ if (c) {
ZVAL_DUP(result, &c->value);
+ return 1;
}
- return retval;
+ return 0;
}
ZEND_API int zend_get_constant_ex(const char *name, uint name_len, zval *result, zend_class_entry *scope, ulong flags TSRMLS_DC)
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
{
- if (!Z_DELREF_P(zval_ptr)) {
- ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
- GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
- zval_dtor(zval_ptr);
- efree_rel(zval_ptr);
- } else {
- if (Z_REFCOUNT_P(zval_ptr) == 1 && Z_TYPE_P(zval_ptr) == IS_REFERENCE) {
- /* convert reference to regular value */
- zend_reference *ref = Z_REF_P(zval_ptr);
- *zval_ptr = ref->val;
- efree_rel(ref);
+ if (IS_REFCOUNTED(Z_TYPE_P(zval_ptr))) {
+ if (!Z_DELREF_P(zval_ptr)) {
+ ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
+ GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
+ zval_dtor(zval_ptr);
+ } else {
+ if (Z_REFCOUNT_P(zval_ptr) == 1 && Z_TYPE_P(zval_ptr) == IS_REFERENCE) {
+ /* convert reference to regular value */
+ zend_reference *ref = Z_REF_P(zval_ptr);
+ ZVAL_COPY_VALUE(zval_ptr, &ref->val);
+ efree_rel(ref);
+ }
+ GC_ZVAL_CHECK_POSSIBLE_ROOT(zval_ptr);
}
-
- GC_ZVAL_CHECK_POSSIBLE_ROOT(zval_ptr);
}
}
static zend_always_inline void i_zval_ptr_dtor_nogc(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
{
- if (!Z_DELREF_P(zval_ptr)) {
- ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
- GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
- zval_dtor(zval_ptr);
- efree_rel(zval_ptr);
- } else {
- if (Z_REFCOUNT_P(zval_ptr) == 1 && Z_TYPE_P(zval_ptr) == IS_REFERENCE) {
- /* convert reference to regular value */
- zend_reference *ref = Z_REF_P(zval_ptr);
- *zval_ptr = ref->val;
- efree_rel(ref);
+ if (IS_REFCOUNTED(Z_TYPE_P(zval_ptr))) {
+ if (!Z_DELREF_P(zval_ptr)) {
+ ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
+ GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
+ zval_dtor(zval_ptr);
+ } else {
+ if (Z_REFCOUNT_P(zval_ptr) == 1 && Z_TYPE_P(zval_ptr) == IS_REFERENCE) {
+ /* convert reference to regular value */
+ zend_reference *ref = Z_REF_P(zval_ptr);
+ ZVAL_COPY_VALUE(zval_ptr, &ref->val);
+ efree_rel(ref);
+ }
}
}
}
char str_result[MAX_LENGTH_OF_LONG];
i_op1 = atoi(Z_STRVAL_P(op1));
- free(Z_STRVAL_P(op1));
+ STR_FREE(Z_STR_P(op1));
if (op2) {
i_op2 = atoi(Z_STRVAL_P(op2));
- free(Z_STRVAL_P(op2));
+ STR_FREE(Z_STR_P(op2));
} else {
i_op2 = 0;
}
convert_to_string(&z_constant);
ZVAL_PSTRINGL(result, Z_STRVAL(z_constant), Z_STRLEN(z_constant));
zval_dtor(&z_constant);
- free(Z_STRVAL_P(name));
+ STR_FREE(Z_STR_P(name));
} else {
*result = *name;
}
printf("SECTION: [%s]\n", Z_STRVAL($2));
#endif
ZEND_INI_PARSER_CB(&$2, NULL, NULL, ZEND_INI_PARSER_SECTION, ZEND_INI_PARSER_ARG TSRMLS_CC);
- free(Z_STRVAL($2));
+ STR_FREE(Z_STR($2));
}
| TC_LABEL '=' string_or_value {
#if DEBUG_CFG_PARSER
printf("NORMAL: '%s' = '%s'\n", Z_STRVAL($1), Z_STRVAL($3));
#endif
ZEND_INI_PARSER_CB(&$1, &$3, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC);
- free(Z_STRVAL($1));
- free(Z_STRVAL($3));
+ STR_FREE(Z_STR($1));
+ STR_FREE(Z_STR($3));
}
| TC_OFFSET option_offset ']' '=' string_or_value {
#if DEBUG_CFG_PARSER
printf("OFFSET: '%s'[%s] = '%s'\n", Z_STRVAL($1), Z_STRVAL($2), Z_STRVAL($5));
#endif
ZEND_INI_PARSER_CB(&$1, &$5, &$2, ZEND_INI_PARSER_POP_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC);
- free(Z_STRVAL($1));
- free(Z_STRVAL($2));
- free(Z_STRVAL($5));
+ STR_FREE(Z_STR($1));
+ STR_FREE(Z_STR($2));
+ STR_FREE(Z_STR($5));
}
- | TC_LABEL { ZEND_INI_PARSER_CB(&$1, NULL, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC); free(Z_STRVAL($1)); }
+ | TC_LABEL { ZEND_INI_PARSER_CB(&$1, NULL, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC); STR_FREE(Z_STR($1)); }
| END_OF_LINE
;
;
encapsed_list:
- encapsed_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
- | encapsed_list TC_QUOTED_STRING { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
+ encapsed_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
+ | encapsed_list TC_QUOTED_STRING { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
| /* empty */ { zend_ini_init_string(&$$); }
;
cfg_var_ref { $$ = $1; }
| constant_literal { $$ = $1; }
| '"' encapsed_list '"' { $$ = $2; }
- | var_string_list_section cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
- | var_string_list_section constant_literal { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
- | var_string_list_section '"' encapsed_list '"' { zend_ini_add_string(&$$, &$1, &$3); free(Z_STRVAL($3)); }
+ | var_string_list_section cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
+ | var_string_list_section constant_literal { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
+ | var_string_list_section '"' encapsed_list '"' { zend_ini_add_string(&$$, &$1, &$3); STR_FREE(Z_STR($3)); }
;
var_string_list:
cfg_var_ref { $$ = $1; }
| constant_string { $$ = $1; }
| '"' encapsed_list '"' { $$ = $2; }
- | var_string_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
- | var_string_list constant_string { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
- | var_string_list '"' encapsed_list '"' { zend_ini_add_string(&$$, &$1, &$3); free(Z_STRVAL($3)); }
+ | var_string_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
+ | var_string_list constant_string { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
+ | var_string_list '"' encapsed_list '"' { zend_ini_add_string(&$$, &$1, &$3); STR_FREE(Z_STR($3)); }
;
expr:
;
cfg_var_ref:
- TC_DOLLAR_CURLY TC_VARNAME '}' { zend_ini_get_var(&$$, &$2 TSRMLS_CC); free(Z_STRVAL($2)); }
+ TC_DOLLAR_CURLY TC_VARNAME '}' { zend_ini_get_var(&$$, &$2 TSRMLS_CC); STR_FREE(Z_STR($2)); }
;
constant_literal: