com php-src: Use better data structures (incomplete): Zend/zend_API.c Zend/zend_compile.c ext/standard/ba sic_functions.c
| From: | Dmitry Stogov | Date: | Fri, 21 Feb 2014 19:51:08 +0000 |
| Subject: | com php-src: Use better data structures (incomplete): Zend/zend_API.c Zend/zend_compile.c ext/standard/ba sic_functions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78025@lists.php.net to get a copy of this message | ||
Commit: d149228b696b1692c682a721aa03825d33aecab8
Author: Dmitry Stogov <dmitry@zend.com> Fri, 21 Feb 2014 23:51:08 +0400
Parents: 6454684212b4687167cc058ad77972f2d456cf20
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d149228b696b1692c682a721aa03825d33aecab8
Log:
Use better data structures (incomplete)
Changed paths:
M Zend/zend_API.c
M Zend/zend_compile.c
M ext/standard/basic_functions.c
Diff:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index f77aaaa..b7b5792 100644
--- a/Zend/zend_API..c
+++ b/Zend/zend_API.c
@@ -2720,13 +2720,13 @@ static int zend_is_callable_check_class(zend_string *name,
zend_fcall_info_cache
} else {
fcc->called_scope = EG(called_scope);
fcc->calling_scope = EG(scope);
- if (!fcc->object_ptr) {
+ if (!fcc->object_ptr && Z_TYPE(EG(This)) == IS_OBJECT) {
fcc->object_ptr = &EG(This);
}
ret = 1;
}
} else if (name_len == sizeof("parent") - 1 &&
- !memcmp(lcname, "parent", sizeof("parent") - 1)) {
+ !memcmp(lcname->val, "parent", sizeof("parent") - 1)) {
if (!EG(scope)) {
if (error) *error = estrdup("cannot access parent:: when no class scope is active");
} else if (!EG(scope)->parent) {
@@ -2734,20 +2734,20 @@ static int zend_is_callable_check_class(zend_string *name,
zend_fcall_info_cache
} else {
fcc->called_scope = EG(called_scope);
fcc->calling_scope = EG(scope)->parent;
- if (!fcc->object_ptr) {
+ if (!fcc->object_ptr && Z_TYPE(EG(This)) == IS_OBJECT) {
fcc->object_ptr = &EG(This);
}
*strict_class = 1;
ret = 1;
}
} else if (name_len == sizeof("static") - 1 &&
- !memcmp(lcname, "static", sizeof("static") - 1)) {
+ !memcmp(lcname->val, "static", sizeof("static") - 1)) {
if (!EG(called_scope)) {
if (error) *error = estrdup("cannot access static:: when no class scope is active");
} else {
fcc->called_scope = EG(called_scope);
fcc->calling_scope = EG(called_scope);
- if (!fcc->object_ptr) {
+ if (!fcc->object_ptr && Z_TYPE(EG(This)) == IS_OBJECT) {
fcc->object_ptr = &EG(This);
}
*strict_class = 1;
@@ -2770,7 +2770,7 @@ static int zend_is_callable_check_class(zend_string *name,
zend_fcall_info_cache
} else {
if (error) zend_spprintf(error, 0, "class '%.*s' not found", name_len,
name->val);
}
- efree(lcname);
+ STR_FREE(lcname);
return ret;
}
/* }}} */
@@ -2779,7 +2779,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable,
zend_fca
{
zend_class_entry *ce_org = fcc->calling_scope;
int retval = 0;
- zend_string *mname;
+ zend_string *mname, *cname;
zend_string *lmname;
const char *colon;
int clen, mlen;
@@ -2834,10 +2834,13 @@ static int zend_is_callable_check_func(int check_flags, zval *callable,
zend_fca
EG(scope) = ce_org;
}
- if (!zend_is_callable_check_class(Z_STR_P(callable), fcc, &strict_class, error TSRMLS_CC)) {
+ cname = STR_INIT(Z_STRVAL_P(callable), clen, 0);
+ if (!zend_is_callable_check_class(cname, fcc, &strict_class, error TSRMLS_CC)) {
+ STR_RELEASE(cname);
EG(scope) = last_scope;
return 0;
}
+ STR_RELEASE(cname);
EG(scope) = last_scope;
ftable = &fcc->calling_scope->function_table;
@@ -3024,12 +3027,13 @@ get_function_via_handler:
}
} else if (error && !(check_flags & IS_CALLABLE_CHECK_SILENT)) {
if (fcc->calling_scope) {
- if (error) zend_spprintf(error, 0, "class '%s' does not have a method
'%s'", fcc->calling_scope->name, mname);
+ if (error) zend_spprintf(error, 0, "class '%s' does not have a method
'%s'", fcc->calling_scope->name->val, mname->val);
} else {
- if (error) zend_spprintf(error, 0, "function '%s' does not exist", mname);
+ if (error) zend_spprintf(error, 0, "function '%s' does not exist",
mname->val);
}
}
- efree(lmname);
+ STR_FREE(lmname);
+ STR_RELEASE(mname);
if (fcc->object_ptr) {
fcc->called_scope = Z_OBJCE_P(fcc->object_ptr);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 9219e28..a54aee8 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3791,7 +3791,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry
*parent
if (parent_ce->default_static_members_count) {
int i = ce->default_static_members_count + parent_ce->default_static_members_count;
- ce->default_static_members_table = erealloc(ce->default_static_members_table,
sizeof(void*) * i);
+ ce->default_static_members_table = erealloc(ce->default_static_members_table, sizeof(zval)
* i);
if (ce->default_static_members_count) {
while (i-- > parent_ce->default_static_members_count) {
ce->default_static_members_table[i] = ce->default_static_members_table[i -
parent_ce->default_static_members_count];
@@ -3809,7 +3809,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry
*parent
if (parent_ce->default_static_members_count) {
int i = ce->default_static_members_count + parent_ce->default_static_members_count;
- ce->default_static_members_table = perealloc(ce->default_static_members_table,
sizeof(void*) * i, ce->type == ZEND_INTERNAL_CLASS);
+ ce->default_static_members_table = perealloc(ce->default_static_members_table,
sizeof(zval) * i, ce->type == ZEND_INTERNAL_CLASS);
if (ce->default_static_members_count) {
while (i-- > parent_ce->default_static_members_count) {
ce->default_static_members_table[i] = ce->default_static_members_table[i -
parent_ce->default_static_members_count];
@@ -5434,7 +5434,6 @@ void zend_do_declare_property(znode *var_name, const znode *value, zend_uint
acc
void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_DC) /* {{{ */
{
zval property;
- zend_string *cname = NULL;
if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
zend_error_noreturn(E_COMPILE_ERROR, "Arrays are not allowed in class constants");
@@ -5447,8 +5446,8 @@ void zend_do_declare_class_constant(znode *var_name, const znode *value
TSRMLS_D
ZVAL_COPY_VALUE(&property, &value->u.constant);
- cname = zend_new_interned_string(Z_STR(var_name->u.constant) TSRMLS_CC);
- if (zend_hash_add(&CG(active_class_entry)->constants_table, cname, &property) == NULL)
{
+ Z_STR(var_name->u.constant) = zend_new_interned_string(Z_STR(var_name->u.constant)
TSRMLS_CC);
+ if (zend_hash_add(&CG(active_class_entry)->constants_table, Z_STR(var_name->u.constant),
&property) == NULL) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s",
CG(active_class_entry)->name->val, Z_STRVAL(var_name->u.constant));
}
FREE_PNODE(var_name);
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index c50e9b9..388042b 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -4970,6 +4970,7 @@ void user_shutdown_function_dtor(zval *zv) /* {{{ */
zval_ptr_dtor(&shutdown_function_entry->arguments[i]);
}
efree(shutdown_function_entry->arguments);
+ efree(shutdown_function_entry);
}
/* }}} */
@@ -4984,8 +4985,9 @@ void user_tick_function_dtor(user_tick_function_entry *tick_function_entry) /*
{
}
/* }}} */
-static int user_shutdown_function_call(php_shutdown_function_entry *shutdown_function_entry
TSRMLS_DC) /* {{{ */
+static int user_shutdown_function_call(zval *zv TSRMLS_DC) /* {{{ */
{
+ php_shutdown_function_entry *shutdown_function_entry = Z_PTR_P(zv);
zval retval;
char *function_name;