]> granicus.if.org Git - php/commitdiff
Fixed apply_func_arg_t, and it's better not using cast (compiler friendly)
authorXinchen Hui <laruence@php.net>
Sun, 25 May 2014 11:56:51 +0000 (19:56 +0800)
committerXinchen Hui <laruence@php.net>
Sun, 25 May 2014 11:56:51 +0000 (19:56 +0800)
Zend/zend_API.c
Zend/zend_builtin_functions.c
Zend/zend_compile.c
Zend/zend_execute_API.c
Zend/zend_ini.c
Zend/zend_list.c

index a52abe3544cd3cacfdd7fcda5dc7e50acdb9db19..01cdefcc133971a0749ecfeb6e5904fe5f563cfb 100644 (file)
@@ -1095,7 +1095,7 @@ ZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC) /* {{{ */
 }
 /* }}} */
 
-static int zend_merge_property(zval *value TSRMLS_DC, int num_args, va_list args, const zend_hash_key *hash_key) /* {{{ */
+static int zend_merge_property(zval *value TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
 {
        /* which name should a numeric property have ? */
        if (hash_key->key) {
@@ -1119,7 +1119,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destro
        zend_class_entry *old_scope = EG(scope);
 
        EG(scope) = Z_OBJCE_P(obj);
-       zend_hash_apply_with_arguments(properties TSRMLS_CC, (apply_func_args_t)zend_merge_property, 2, obj, obj_ht);
+       zend_hash_apply_with_arguments(properties TSRMLS_CC, zend_merge_property, 2, obj, obj_ht);
        EG(scope) = old_scope;
 
        if (destroy_ht) {
@@ -2453,9 +2453,11 @@ ZEND_API int zend_get_module_started(const char *module_name) /* {{{ */
 }
 /* }}} */
 
-static int clean_module_class(const zend_class_entry **ce, int *module_number TSRMLS_DC) /* {{{ */
+static int clean_module_class(zval *el, void *arg TSRMLS_DC) /* {{{ */
 {
-       if ((*ce)->type == ZEND_INTERNAL_CLASS && (*ce)->info.internal.module->module_number == *module_number) {
+       zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el);
+       int module_number = *(int *)arg;
+       if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module->module_number == module_number) {
                return ZEND_HASH_APPLY_REMOVE;
        } else {
                return ZEND_HASH_APPLY_KEEP;
@@ -2465,7 +2467,7 @@ static int clean_module_class(const zend_class_entry **ce, int *module_number TS
 
 static void clean_module_classes(int module_number TSRMLS_DC) /* {{{ */
 {
-       zend_hash_apply_with_argument(EG(class_table), (apply_func_arg_t) clean_module_class, (void *) &module_number TSRMLS_CC);
+       zend_hash_apply_with_argument(EG(class_table), clean_module_class, (void *) &module_number TSRMLS_CC);
 }
 /* }}} */
 
index 77743fbd329bb72810356a934d12a489712a073d..b207d698f8467e66b5c6bfc4f444964e837e19ab 100644 (file)
@@ -1873,7 +1873,7 @@ ZEND_FUNCTION(get_loaded_extensions)
        if (zendext) {
                zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t)add_zendext_info, return_value TSRMLS_CC);
        } else {
-               zend_hash_apply_with_argument(&module_registry, (apply_func_arg_t)add_extension_info, return_value TSRMLS_CC);
+               zend_hash_apply_with_argument(&module_registry, add_extension_info, return_value TSRMLS_CC);
        }
 }
 /* }}} */
@@ -1939,7 +1939,7 @@ ZEND_FUNCTION(get_defined_constants)
                efree(module_names);
                efree(modules);
        } else {
-               zend_hash_apply_with_argument(EG(zend_constants), (apply_func_arg_t)add_constant_info, return_value TSRMLS_CC);
+               zend_hash_apply_with_argument(EG(zend_constants), add_constant_info, return_value TSRMLS_CC);
        }
 }
 /* }}} */
index 20e4b5f341cbe15cf6c755180de2135d92b5e3d3..ed1b9806333fcf0600d14574f0e419bea88059a8 100644 (file)
@@ -4101,9 +4101,10 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
 }
 /* }}} */
 
-static int zend_fixup_trait_method(zval *zv, zend_class_entry *ce TSRMLS_DC) /* {{{ */
+static int zend_fixup_trait_method(zval *zv, void *arg TSRMLS_DC) /* {{{ */
 {
        zend_function *fn = Z_PTR_P(zv);
+       zend_class_entry *ce = (zend_class_entry *)arg;
                
        if ((fn->common.scope->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
 
@@ -4368,15 +4369,15 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{
                        zend_traits_compile_exclude_table(&exclude_table, ce->trait_precedences, ce->traits[i]);
 
                        /* copies functions, applies defined aliasing, and excludes unused trait methods */
-                       zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, (apply_func_args_t)zend_traits_copy_functions, 3, ce, &overriden, &exclude_table);
+                       zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, zend_traits_copy_functions, 3, ce, &overriden, &exclude_table);
 
                        zend_hash_destroy(&exclude_table);
                } else {
-                       zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, (apply_func_args_t)zend_traits_copy_functions, 3, ce, &overriden, NULL);
+                       zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, zend_traits_copy_functions, 3, ce, &overriden, NULL);
                }
        }
 
-    zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t)zend_fixup_trait_method, ce TSRMLS_CC);
+    zend_hash_apply_with_argument(&ce->function_table, zend_fixup_trait_method, ce TSRMLS_CC);
 
        if (overriden) {
                zend_hash_destroy(overriden);
index a891f97e0807ebe7cbc90fa7d7736885b596d07b..2b62f2e844cb0a549c57d0353ea09f0569c4163c 100644 (file)
@@ -1541,9 +1541,10 @@ typedef struct _zend_abstract_info {
        int ctor;
 } zend_abstract_info;
 
-static int zend_verify_abstract_class_function(zval *zv, zend_abstract_info *ai TSRMLS_DC) /* {{{ */
+static int zend_verify_abstract_class_function(zval *zv, void *arg TSRMLS_DC) /* {{{ */
 {
-       zend_function *fn = Z_PTR_P(zv);
+       zend_function *fn = (zend_function *)Z_PTR_P(zv);
+       zend_abstract_info *ai = (zend_abstract_info *)arg;
 
        if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
                if (ai->cnt < MAX_ABSTRACT_INFO_CNT) {
@@ -1571,7 +1572,7 @@ void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC) /* {{{ */
        if ((ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) && !(ce->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
                memset(&ai, 0, sizeof(ai));
 
-               zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t) zend_verify_abstract_class_function, &ai TSRMLS_CC);
+               zend_hash_apply_with_argument(&ce->function_table, zend_verify_abstract_class_function, &ai TSRMLS_CC);
 
                if (ai.cnt) {
                        zend_error(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
index ca4e4d7863404ff7a6e1ef3c96699270b85eb228..6f4cd4fd38dcc1c88874a3702f00c4c760e09289 100644 (file)
@@ -34,8 +34,9 @@ static HashTable *registered_zend_ini_directives;
 /*
  * hash_apply functions
  */
-static int zend_remove_ini_entries(zend_ini_entry *ini_entry, int *module_number TSRMLS_DC) /* {{{ */
+static int zend_remove_ini_entries(zval *el, int *module_number TSRMLS_DC) /* {{{ */
 {
+       zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
        if (ini_entry->module_number == *module_number) {
                return 1;
        } else {
@@ -224,13 +225,14 @@ ZEND_API int zend_register_ini_entries(const zend_ini_entry *ini_entry, int modu
 
 ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC) /* {{{ */
 {
-       zend_hash_apply_with_argument(registered_zend_ini_directives, (apply_func_arg_t) zend_remove_ini_entries, (void *) &module_number TSRMLS_CC);
+       zend_hash_apply_with_argument(registered_zend_ini_directives, zend_remove_ini_entries, (void *) &module_number TSRMLS_CC);
 }
 /* }}} */
 
 #ifdef ZTS
-static int zend_ini_refresh_cache(zend_ini_entry *p, int stage TSRMLS_DC) /* {{{ */
+static int zend_ini_refresh_cache(zval *el, int stage TSRMLS_DC) /* {{{ */
 {
+       zend_ini_entry *p = (zend_ini_entry *)Z_PTR_P(el);
        if (p->on_modify) {
                p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage TSRMLS_CC);
        }
@@ -240,7 +242,7 @@ static int zend_ini_refresh_cache(zend_ini_entry *p, int stage TSRMLS_DC) /* {{{
 
 ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC) /* {{{ */
 {
-       zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) zend_ini_refresh_cache, (void *)(zend_intptr_t) stage TSRMLS_CC);
+       zend_hash_apply_with_argument(EG(ini_directives), zend_ini_refresh_cache, (void *)(zend_intptr_t) stage TSRMLS_CC);
 }
 /* }}} */
 #endif
index 41565408bac37cf002478fce8a78ea71a666d40d..f496dd271a39b1bd07173754d76a42676230eac2 100644 (file)
@@ -242,7 +242,7 @@ static int zend_clean_module_rsrc_dtors_cb(zval *zv, int *module_number TSRMLS_D
 {
        zend_rsrc_list_dtors_entry *ld = Z_PTR_P(zv);   
        if (ld->module_number == *module_number) {
-               zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC);
+               zend_hash_apply_with_argument(&EG(persistent_list), clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC);
                return 1;
        } else {
                return 0;
@@ -252,7 +252,7 @@ static int zend_clean_module_rsrc_dtors_cb(zval *zv, int *module_number TSRMLS_D
 
 void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC)
 {
-       zend_hash_apply_with_argument(&list_destructors, (apply_func_arg_t) zend_clean_module_rsrc_dtors_cb, (void *) &module_number TSRMLS_CC);
+       zend_hash_apply_with_argument(&list_destructors, zend_clean_module_rsrc_dtors_cb, (void *) &module_number TSRMLS_CC);
 }