Hi,
I am using C with php. ZEND_FETCH_RESOURCE() is not returning actual value.
Detail is as:
static int le_gtest=-1;
static zval zval_rscrid=-1;
static int iPtr;
In PHP_MINIT_FUNCTION(..):-
le_gtest = zend_register_list_destructors_ex(destroy_resource, NULL, "myglobal_resource", module_number);
In "set_resorce" function :-
zval handle;
MAKE_STD_ZVAL(handle);
iPtr=emalloc(sizeof(int));
iPtr=100;
MAKE_STD_ZVAL(zval_rscrid);
zval_rscrid->type=IS_RESOURCE;
zval_rscrid->value.lval=ZEND_REGISTER_RESOURCE(handle,&iPtr, le_gtest);
In "get_resorce" function :-
ZEND_FETCH_RESOURCE(iPtr, int *,&zval_rscrid , -1, "myglobal_resource", le_gtest);
if(!iPtr)
{
RETURN_FALSE;
}
else
{
RETURN_LONG(*iPtr);
}
In abc.php file I do:
<?
set_resource();
$myvar =get_resource();
echo $myvar ;
?>
The output is: 1073968092 (not 100 ?)
Other function call of c library is ok.
help please