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) {
PHP_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;
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.
johannes