Re: Help: call_user_function() core dumps
| From: | Dhiru Pandey | Date: | Fri, 02 May 2008 01:09:29 +0000 |
| Subject: | Re: Help: call_user_function() core dumps | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37398@lists.php.net to get a copy of this message | ||
Thanks Johannes,
Your suggestions were spot on. Thanks again - Dhiru
Johannes Schlüter wrote:
Hi, On Wed, 2008-04-30 at 09:52 -0700, Dhiru Pandey wrote:I am new to PHP extension writing and embedding. Following the book from Sara Goleman - Extending and Embedding PHP (Developer's Library) I wrote the following program based on her example in Chap. 20 =================================================================== #include <stdio.h> #include <stdlib.h> #include <sapi/embed/php_embed.h> int main(int argc, char** argv) {You have to use emalloc'ed memory for (basically) everything you give to the engine and no pointers to local variables else the engine tries to free these local variables. johannesPHP_EMBED_START_BLOCK(argc, argv);zval* args[2]; zval funcname; zval input_str; zval count; zval retval; char* ans; ZVAL_STRING(&funcname, "str_repeat", 0); args[0] = &input_str; args[1] = &count;