Sorry, sent the message accidentally :-/ The new Gmail UI.... fci and fcc are just stack variables that are destroyed when the function is done.
zend_fcall_info fci = empty_fcall_info; zend_fcall_info_cache fcc = empty_fcall_info_cache; But I want to store the info in some internal structure where I can do two things: a) declare zend_fcall_info/cache variables b) declare pointers to zend_fcall_info/cache I chosen b). Thus, I allocate memory for my structure, allocate memory for zend_fcall_info/cache pointers and copy contents of the stack variables into the heap memory where I store zend_fcall_info/cache pointers. I use PHP_EVENT_COPY_FCALL_INFO macro in my extension: https://bitbucket.org/osmanov/pecl-event/src/7da635cc1da46c5ac85af15ac6da4753d112066e/php_event.h?at=master#cl-80 I'll quote some code from it: Z_ADDREF_P(pfci->function_name); \ if (pfci->object_ptr) { \ Z_ADDREF_P(pfci->object_ptr); \ } The code is okay in most cases, as I said. But there is a special case, when incrementing refcount of object_ptr prevents Zend MM to call the object dtors. It is the case when object_ptr refers to "this_ptr". Let's look at example: http://bpaste.net/show/118596/ . As you can see, the dtors are called on the shutdown phase. The cause is refcount of pfci->object_ptr, which points to the caller class object($this) in the $callback argument. So what is the proper way to deal with zend_fcall_info.object_ptr's refcount? I didn't find a Zend API function to copy fcall info. I also didn't find a way to obtain the caller's "this_ptr" pointer. EG(This) points to current (Event) this_ptr, not Foo's this_ptr. Please help to figure it out. On Tue, Jul 30, 2013 at 3:24 PM, Ruslan Osmanov <[email protected]> wrote: > Hi, > > let's suppose we've a method accepting a "callable" argument. The callable > should be stored in some internal structure. I'm asking for help with the > refcounts inside zend_fcall_info. Most of time we have to increment > refcount of object_ptr memeber. But sometimes not. I'll explain. > > The recommended way to accept a callable is using the "f" option of > zend_parse_arguments, e.g.: > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fcc) == > FAILURE) { > return; > } > > > > -- > Regards > -- Regards, Ruslan Osmanov http://osmanov-dev-notes.blogspot.com | @ruslan_osmanov
