Re: Help, please! The Zend API is driving me mad!!!
| From: | (Marcus B�rger) | Date: | Tue, 17 Jun 2003 19:29:38 +0000 |
| Subject: | Re: Help, please! The Zend API is driving me mad!!! | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-2356@lists.php.net to get a copy of this message | ||
Hello Oriol,
Tuesday, June 17, 2003, 6:29:14 PM, you wrote:
O> Aaaaaaaaaaargh!
O> When I run the following code...
O> ----------------------------------------------
O> char fname[256];
O> zval **retval;
O> zval *zfname;
O> strcpy(fname, "rand");
O> zend_printf("Step 1...\n");
O> MAKE_STD_ZVAL(zfname);
O> zend_printf("Step 2...\n");
O> ZVAL_STRING(zfname, fname, 1);
O> zend_printf("Step 3...\n");
O> TSRMLS_FETCH();
O> zend_printf("Step 4...\n");
O> if (call_user_function_ex(CG(function_table), NULL,
O> zfname, retval, 0, NULL, 0,
O> NULL TSRMLS_DC) == SUCCESS)
O> {
O> zend_printf("The function has ben called.\n");
O> }
O> -----------------------------------------------
O> ... i get:
O> Step 1...
O> Step 2...
O> Step 3...
O> Step 4...
O> Segmentation fault
O> Could someone tell me what I'm doing wrong?
O> Thank you very much,
- The line TSRMLS_FETCH() must be the last line after all local variable
declarations.
- TSRMLS_DC must be replaced with TSRMLS_CC in the
call_user_function_ex() call.
- CG means Compiler Globals so i guess you want the corresponging
Executor Global_ EG(function_table)
- If the third parameter to ZVAL_STRING() is a non zero value the
string value is copied to the zval. Since it must be freeable by the
zval destructor it must be a value stroed in memory allocated by
emalloc(). Where this happens doesn't matter so the following is
enough: ZVAL_STRING(zfname, "rand", 1);
--
Best regards,
Marcus mailto:helly@php.net