felipe Fri Jun 20 19:57:25 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/wddx wddx.c
Log:
- New parameter parsing API
http://cvs.php.net/viewvc.cgi/php-src/ext/wddx/wddx.c?r1=1.119.2.10.2.17.2.5&r2=1.119.2.10.2.17.2.6&diff_format=u
Index: php-src/ext/wddx/wddx.c
diff -u php-src/ext/wddx/wddx.c:1.119.2.10.2.17.2.5
php-src/ext/wddx/wddx.c:1.119.2.10.2.17.2.6
--- php-src/ext/wddx/wddx.c:1.119.2.10.2.17.2.5 Tue Apr 29 08:15:20 2008
+++ php-src/ext/wddx/wddx.c Fri Jun 20 19:57:25 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: wddx.c,v 1.119.2.10.2.17.2.5 2008/04/29 08:15:20 dmitry Exp $ */
+/* $Id: wddx.c,v 1.119.2.10.2.17.2.6 2008/06/20 19:57:25 felipe Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1148,20 +1148,12 @@
Creates a new packet and serializes given variables into a struct */
PHP_FUNCTION(wddx_serialize_vars)
{
- int argc, i;
+ int num_args, i;
wddx_packet *packet;
- zval ***args;
-
- argc = ZEND_NUM_ARGS();
- if (argc < 1) {
- WRONG_PARAM_COUNT;
- }
+ zval ***args = NULL;
- /* Allocate arguments array and get the arguments, checking for errors.
*/
- args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
- if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args,
&num_args) == FAILURE) {
+ return;
}
packet = php_wddx_constructor();
@@ -1169,9 +1161,10 @@
php_wddx_packet_start(packet, NULL, 0);
php_wddx_add_chunk_static(packet, WDDX_STRUCT_S);
- for (i=0; i<argc; i++) {
- if (Z_TYPE_PP(args[i]) != IS_ARRAY && Z_TYPE_PP(args[i]) !=
IS_OBJECT)
+ for (i=0; i<num_args; i++) {
+ if (Z_TYPE_PP(args[i]) != IS_ARRAY && Z_TYPE_PP(args[i]) !=
IS_OBJECT) {
convert_to_string_ex(args[i]);
+ }
php_wddx_add_var(packet, *args[i]);
}
@@ -1256,39 +1249,29 @@
Serializes given variables and adds them to packet given by packet_id */
PHP_FUNCTION(wddx_add_vars)
{
- int argc, i;
- zval ***args;
- zval **packet_id;
+ int num_args, i;
+ zval ***args = NULL;
+ long packet_id;
wddx_packet *packet = NULL;
- argc = ZEND_NUM_ARGS();
- if (argc < 2) {
- WRONG_PARAM_COUNT;
- }
-
- /* Allocate arguments array and get the arguments, checking for errors.
*/
- args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
- if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
- efree(args);
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l+", packet_id,
&args, &num_args) == FAILURE) {
+ return;
}
-
- packet_id = args[0];
- packet = (wddx_packet *)zend_fetch_resource(packet_id TSRMLS_CC, -1,
"WDDX packet ID", NULL, 1, le_wddx);
- if (!packet)
- {
+ packet = (wddx_packet *)zend_fetch_resource(&packet_id TSRMLS_CC, -1,
"WDDX packet ID", NULL, 1, le_wddx);
+ if (!packet) {
efree(args);
RETURN_FALSE;
}
- for (i=1; i<argc; i++) {
- if (Z_TYPE_PP(args[i]) != IS_ARRAY && Z_TYPE_PP(args[i]) !=
IS_OBJECT)
+ for (i=1; i<num_args; i++) {
+ if (Z_TYPE_PP(args[i]) != IS_ARRAY && Z_TYPE_PP(args[i]) !=
IS_OBJECT) {
convert_to_string_ex(args[i]);
+ }
php_wddx_add_var(packet, (*args[i]));
}
- efree(args);
+ efree(args);
RETURN_TRUE;
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php