Hi Bill,
> I don't know a think about PHP. What's a "resource" vs. and object in
> PHP?
>
PHP 4 does not have "native objects". It uses some sort ort artifice to
emulate them using arrays. But this will change in version 5.
>
> I just took at look at swishe.c at
>
> http://cvs.sourceforge.net/viewcvs.py/swishe/swish_php/swishe.c?rev=
> 1.1&content-type=text/vnd.viewcvs-markup
>
> Is that programmed to the current 2.4.0 API?
>
Yep. I have it in production with PR3.
> I see these:
>
> void _php_swishe_search_close(zend_rsrc_list_entry *rsrc)
> {
> php_swishe_search *search = (php_swishe_search *)rsrc->ptr;
>
> efree(search);
> }
>
> /* destroy a resource of type "swishe_results" */
> static void _php_swishe_results_close(zend_rsrc_list_entry *rsrc) {
> php_swishe_results *results = (php_swishe_results *)rsrc->ptr;
>
> efree(results);
> }
>
>
> /* destroy a resource of type "swishe_result" */
> static void _php_swishe_result_close(zend_rsrc_list_entry *rsrc)
> {
> php_swishe_result *result = (php_swishe_result *)rsrc->ptr;
>
> efree(result);
> }
>
> How are they called when using the PHP interface?
>
I am not sure of what I am going to say because it is hard to find
documentation about this issues. I just based the code in some
samples that I could find.
I think that PHP frees the resources for you when the page ends.
How PHP is able to do that thing?
Well, the destructors (_php_swishe_close, _php_swishe_search_clos,
etc.) are registered in PHP_MINIT_FUNCTION.
Also, when an "object" is created it is also registered with its destructor.
Internally, PHP holds a list of the created objects and when the page
ends it calls the destructors for all the created objects.
So, you do not need to take care of destroying them.
I can be wrong. So, any advice is welcome.
cu
Jose
Received on Fri Oct 10 20:53:12 2003