]> granicus.if.org Git - php/commitdiff
Support the latest update to call_user_function_ex()
authorZeev Suraski <zeev@php.net>
Sun, 19 Dec 1999 18:58:27 +0000 (18:58 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 19 Dec 1999 18:58:27 +0000 (18:58 +0000)
ext/standard/array.c
ext/standard/basic_functions.c

index 02a855a5d0d89d77ea62493c3d6072af13056741..e18d122b4b8d5fc855ab8dea2eb793b3a4572581 100644 (file)
@@ -387,7 +387,7 @@ static int array_user_compare(const void *a, const void *b)
        Bucket *f;
        Bucket *s;
        pval **args[2];
-       pval retval;
+       pval *retval_ptr;
        CLS_FETCH();
        BLS_FETCH();
 
@@ -397,9 +397,14 @@ static int array_user_compare(const void *a, const void *b)
        args[0] = (pval **) f->pData;
        args[1] = (pval **) s->pData;
 
-       if (call_user_function_ex(CG(function_table), NULL, *BG(user_compare_func_name), &retval, 2, args, 0)==SUCCESS) {
-               convert_to_long(&retval);
-               return retval.value.lval;
+       if (call_user_function_ex(CG(function_table), NULL, *BG(user_compare_func_name), &retval_ptr, 2, args, 0)==SUCCESS
+               && retval_ptr) {
+               long retval;
+
+               convert_to_long_ex(&retval_ptr);
+               retval = retval_ptr->value.lval;
+               zval_ptr_dtor(&retval_ptr);
+               return retval;
        } else {
                return 0;
        }
@@ -795,7 +800,7 @@ PHP_FUNCTION(max)
 static int php_array_walk(HashTable *target_hash, zval **userdata)
 {
        zval **args[3],                 /* Arguments to userland function */
-                  retval,                      /* Return value - unused */
+                 *retval_ptr,                  /* Return value - unused */
                  *key;                         /* Entry key */
        char  *string_key;
        ulong  num_key;
@@ -823,8 +828,11 @@ static int php_array_walk(HashTable *target_hash, zval **userdata)
                
                /* Call the userland function */
                call_user_function_ex(CG(function_table), NULL, *BG(array_walk_func_name),
-                                                  &retval, userdata ? 3 : 2, args, 0);
+                                                  &retval_ptr, userdata ? 3 : 2, args, 0);
                
+               if (retval_ptr) {
+                       zval_ptr_dtor(&retval_ptr);
+               }
                /* Clean up the key */
                if (zend_hash_get_current_key_type(target_hash) == HASH_KEY_IS_STRING)
                        efree(key->value.str.val);
index 1328f9c20df0892f0f500fbb71da4bd853c0fae0..86bfddab3829b2cd2b72ca235ae20f892e1973ed 100644 (file)
@@ -943,7 +943,7 @@ PHPAPI int _php_error_log(int opt_err,char *message,char *opt,char *headers){
 PHP_FUNCTION(call_user_func)
 {
        pval ***params;
-       pval retval;
+       pval *retval_ptr;
        int arg_count=ARG_COUNT(ht);
        CLS_FETCH();
        
@@ -958,8 +958,9 @@ PHP_FUNCTION(call_user_func)
        }
        SEPARATE_ZVAL(params[0]);
        convert_to_string(*params[0]);
-       if (call_user_function_ex(CG(function_table), NULL, *params[0], &retval, arg_count-1, params+1, 1)==SUCCESS) {
-               *return_value = retval;
+       if (call_user_function_ex(CG(function_table), NULL, *params[0], &retval_ptr, arg_count-1, params+1, 1)==SUCCESS
+               && retval_ptr) {
+               COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
        } else {
                php_error(E_WARNING,"Unable to call %s() - function does not exist", (*params[0])->value.str.val);
        }
@@ -970,7 +971,7 @@ PHP_FUNCTION(call_user_func)
 PHP_FUNCTION(call_user_method)
 {
        pval ***params;
-       pval retval;
+       pval *retval_ptr;
        int arg_count=ARG_COUNT(ht);
        CLS_FETCH();
        
@@ -991,8 +992,9 @@ PHP_FUNCTION(call_user_method)
        SEPARATE_ZVAL(params[0]);
        SEPARATE_ZVAL(params[1]);
        convert_to_string(*params[0]);
-       if (call_user_function_ex(CG(function_table), *params[1], *params[0], &retval, arg_count-2, params+2, 1)==SUCCESS) {
-               *return_value = retval;
+       if (call_user_function_ex(CG(function_table), *params[1], *params[0], &retval_ptr, arg_count-2, params+2, 1)==SUCCESS
+               && retval_ptr) {
+               COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
        } else {
                php_error(E_WARNING,"Unable to call %s() - function does not exist", (*params[0])->value.str.val);
        }