ZEND_FETCH_RESOURCE mystery
| From: | fabwash | Date: | Wed, 05 Jun 2002 02:21:09 +0000 |
| Subject: | ZEND_FETCH_RESOURCE mystery | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-84867@lists.php.net to get a copy of this message | ||
Hello,
i'm trying to use ZEND_FETCH_RESOURCE so I can use macros instead of other stuff, but i
can't figure out how to use it.
I have the following php code:
$blah = new Blah();
$blah->doSomething();
When Blah() is called, I want to create a structure and store it as a resource:
typedef struct {
int zoo;
long blurb;
} blah_struct;
blah_struct *blah;
I register my resource:
ZEND_REGISTER_RESOURCE(result_returned, &blah, le_blahresource);
In "doSomething" I want to get my resource back, so I try to do:
ZEND_FETCH_RESOURCE(blah, blah_struct *, ????????, "blah", le_blahresource);
This 3rd parameter is a mystery. I checked other modules, and they pass a zval taken from user
input, but in my case, I don't have user input, I just want to get my structure back. What am I
supposed to pass as the 3rd parameter?? I tried passing a reference to the Blah() object, but that
didn't work.
I found a workaround, using zend_list_insert and zend_list_find, but I guess I should be able to use
ZEND_REGISTER and ZEND_FETCH, no?
Fab.