From be24fe6155e8f8d86899fe3c15cc55b573a46b1e Mon Sep 17 00:00:00 2001 From: Shuhei Tanuma Date: Mon, 23 Jul 2012 00:08:05 +0900 Subject: [PATCH] docs: add uv_stdio_new function --- README.md | 1 + examples/spawn.php | 2 +- php_uv.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27d9f20..5b99f1b 100644 --- a/README.md +++ b/README.md @@ -1680,6 +1680,7 @@ var_dump(uv_cpu_info()); ### array uv_interface_addresses(void) +### resource uv_stdio_new(zval $fd, long $flags) ### resource uv_spawn(resource $loop, string $command, array $args, array $stdio, string $cwd, array $env = array(), callable $callback [,long $flags, array $options]) diff --git a/examples/spawn.php b/examples/spawn.php index 81ed788..8c5c162 100644 --- a/examples/spawn.php +++ b/examples/spawn.php @@ -10,7 +10,7 @@ $stdio[] = uv_stdio_new($in, UV::CREATE_PIPE | UV::READABLE_PIPE); $stdio[] = uv_stdio_new($out, UV::CREATE_PIPE | UV::WRITABLE_PIPE); $flags = 0; -uv_spawn(uv_default_loop(), "php", array('-r','echo "WORLD";'), $stdio, "/usr/bin/", +uv_spawn(uv_default_loop(), "php", array('-r','var_dump($_ENV);'), $stdio, "/usr/bin/", array("key"=>"hello"), function($process, $stat, $signal){ uv_close($process,function(){}); diff --git a/php_uv.c b/php_uv.c index 5620ff6..0f4a702 100644 --- a/php_uv.c +++ b/php_uv.c @@ -5067,7 +5067,7 @@ PHP_FUNCTION(uv_spawn) tmp_env = Z_ARRVAL_P(env); - zenv = emalloc(sizeof(char*) * (zend_hash_num_elements(tmp_env)+1)); + zenv = ecalloc(zend_hash_num_elements(tmp_env)+1, sizeof(char*)); for (zend_hash_internal_pointer_reset_ex(tmp_env, &pos); (key_type = zend_hash_get_current_key_ex(tmp_env, &key, &key_len, &key_index, 0, &pos)) != HASH_KEY_NON_EXISTANT; zend_hash_move_forward_ex(tmp_env, &pos)) {