Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40377 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77240 invoked from network); 8 Sep 2008 21:55:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2008 21:55:12 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:43685] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/96-46475-F3F95C84 for ; Mon, 08 Sep 2008 17:55:12 -0400 Received: from MBOERGER-ZRH (unknown [193.142.125.1]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 7F1A411FE50; Mon, 8 Sep 2008 23:55:08 +0200 (CEST) Date: Mon, 8 Sep 2008 23:55:04 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <564726435.20080908235504@marcus-boerger.de> To: "mr esnafrao" CC: "PHP Developers Mailing List" In-Reply-To: <2a149c8c0809080958j12ddbf84l2f0b533569d69557@mail.gmail.com> References: <2a149c8c0809080958j12ddbf84l2f0b533569d69557@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] array and call_user_function From: helly@php.net (Marcus Boerger) Hello mr, Monday, September 8, 2008, 6:58:19 PM, you wrote: > Hi all, > I'm having problems passing an array to the function call_user_function as > parameter. This is the code: > zval *args[3], *func, *retval; args maust be *** not ** > MAKE_STD_ZVAL(func); > MAKE_STD_ZVAL(retval); > MAKE_STD_ZVAL(args[0]); > MAKE_STD_ZVAL(args[1]); > MAKE_STD_ZVAL(args[2]); > ALLOC_HASHTABLE(args[2]); > // creates hash and fills > zend_hash_init(args[2], 0, NULL, NULL, 0); > g_hash_table_iter_init (&iter, m->params); > while (g_hash_table_iter_next (&iter, &key, &value)) { > zend_hash_add(args[2], key, strlen(key), value, strlen(value), > NULL); > } > ZVAL_STRING(args[0], estrdup(m->sender), 0); > ZVAL_STRING(args[1], estrdup(m->cmd), 0); > ZVAL_STRING(func, estrdup(handler), 0); > if (call_user_function(EG(function_table), > NULL, > func, > retval, 3, > args TSRMLS_CC) == FAILURE) { > g_debug("error calling method: %s", handler); > } > zval_dtor(retval); > zval_dtor(func); > zval_dtor(args[0]); > zval_dtor(args[1]); > zend_hash_destroy(args[2]); > FREE_HASHTABLE(args[2]); args[2] is wrong and anyway all three need to be zval_ptr_dtor() marcus > I suppose that the problem is the conversion between the Hash and the zval, > but I don't know how to do it. > Thanks in advance :) > regards Best regards, Marcus