Re: [PHP4BETA] getParametersEx again....

From: Date: Tue, 14 Sep 1999 18:01:12 +0000
Subject: Re: [PHP4BETA] getParametersEx again....
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-4443@lists.php.net to get a copy of this message
At 19:25 14/09/1999 , Thies C. Arntzen wrote:
andi, i think what would be nice would be something like: char *zval_string_value(zval *val,int *length,int *needs_to_be_efreed); int zval_int_value(zval *zval); etc then: ...
        zval *arg;
        getParameters(ht,1,&arg);
        SEPARATE_ZVAL(arg);
        convert_to_string(arg);
        some_func(arg->value.str.val,arg->value.str.len);
... would become: ...
        zval **arg;
        char *strval
        int needsfree;
        int len;
        getParamtetersEx(1,&arg);
        strval = zval_string_value(*arg,&len,&needsfree)
        some_func(strval,len);
        if (needsfree) efree(len);
First, what Andi said about the zendi_*() macros in zend_operators.c was bogus - they're not intended for any sort of API use and aren't related to getParametersEx() in any way... They're used internally inside zend_operators.c for performance. Second - no matter what you use, whether it's getParameters() or getParametersEx(), whether you call SEPARATE_ZVAL() or not - there's no need (and you mustn't) explicitly free it. The framework supports it without requiring you to do anything. All I intend to add is something along the lines of: #define convert_to_long_ex(pz) \
        if ((*pz)->type != IS_LONG) {
                SEPARATE_ZVAL(pz);
                convert_to_long(*pz);
        }
that would make the "first_arg_force_ref" and SEPARATE_ZVAL completly unnecessary *plus * it would be fast(er)! right now people tend to do: $cnt = count(&$array); which is bad style! by using getParamtetersEx the functions have full control!
Hold your horses :) first_arg_force_ref has no relation to getParamtersEx(). In fact, as a rule of the thumb, getParametersEx() gives you no additional functionality - it just provides a quicker API to implement the same things. -> it makes no difference as far as pass-by-reference is concerned. You still have to pass by reference explicitly, whether if you do it when you call the function or when you define the function. I'll try to add these new macros today. Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il

« previous php.version4 (#4443) next »