Freeing arrays in Zend [ Was: Stacktrace in errormessages]

From: Date: Sat, 16 Dec 2000 04:08:36 +0000
Subject: Freeing arrays in Zend [ Was: Stacktrace in errormessages]
Groups: php.dev 
Request: Send a blank email to php-dev+get-41560@lists.php.net to get a copy of this message
Hi I sent this message to the list a few weeks ago, but didn't get any response, so I'm giving it another shot. Specificly, I need to know if the following is correct: zval *a; ALLOC_INIT_ZVAL(a); array_init(a); add_next_index_string(a, string, 1); add_next_index_string(a, string2, 1); // hmm FREE_ZVAL(a); or if it's leaking memory, and I need to do some magic before FREE_ZVAL to free the copies of the strings and the array-metadata. I'd be greatful if anyone cared to review my patch and see if there are other bugs. (http://www.stud.ntnu.no/~ragnarkj/download/php-stacktrace.patch) Thanks. ----- Forwarded message from Ragnar Kjørstad <php@ragnark.vestdata.no> ----- Date: Sun, 19 Nov 2000 00:58:36 +0100 From: Ragnar Kjørstad <php@ragnark.vestdata.no> To: Zeev Suraski <zeev@zend.com> Cc: php-dev@lists.php.net Subject: Re: [PHP-DEV] Stacktrace in errormessages X-Mailer: Mutt 0.95.5i In-Reply-To: <5.0.0.25.2.20001029183232.033fa1f8@mail.zend.com>; from Zeev Suraski on Sun, Oct 29, 2000 at 06:34:04PM +0200 On Sun, Oct 29, 2000 at 06:34:04PM +0200, Zeev Suraski wrote: > >If no, could you give me some hints to where this stack should be > >modified? > > > >I'll try to add the feature - even if you don't think it belongs in the > >php distribution it will be a nice feature for us and possible others. > >(Or if you choose, you can add it with a compile-option). > > Well, it'd have to be added to the execute() code. OK, now it kind of works :-) However, I still have a few problems: * Memory managment - how to free data-structures * will FREE_ZVAL() free the content too, if I free an array? * does zend_stack_del_top() free the content properly? e.g. if it's an object? * How does the reference-counter system work? * How do I create complex datastructures? I found out how to build an array (I think :-) ), but not how to put an array into an array and so on. I'll be greatful for any pointers to documentation (I browsed zend.org but could not find answers to theese questions) or answers to theese specific questions. Once I find out how to do this, I'm going to: * add function arguments to the stack-trace * modify the internal error-handler to print the stack-trace * add an #ifdef or configuration-switch > As I said, though, we > don't want to add it because it'll significantly reduce function call > performance. OK, I'll just maintain it as a seperate patch then. BTW: How do you benchmark this? Run a profiler on the cgi-version of php? Run apachebench on a php-webpage? Any other ways? Thanks -- Ragnar Kjørstad Modus Media ----- End forwarded message -----

« previous php.dev (#41560) next »