davidc          Wed Jun 25 10:16:52 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/standard       formatted_print.c 
  Log:
  Reverted zpp API Cleanup patch - memory troubles?
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/formatted_print.c?r1=1.82.2.1.2.16.2.5&r2=1.82.2.1.2.16.2.6&diff_format=u
Index: php-src/ext/standard/formatted_print.c
diff -u php-src/ext/standard/formatted_print.c:1.82.2.1.2.16.2.5 
php-src/ext/standard/formatted_print.c:1.82.2.1.2.16.2.6
--- php-src/ext/standard/formatted_print.c:1.82.2.1.2.16.2.5    Wed Jun 25 
08:56:42 2008
+++ php-src/ext/standard/formatted_print.c      Wed Jun 25 10:16:52 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: formatted_print.c,v 1.82.2.1.2.16.2.5 2008/06/25 08:56:42 davidc Exp $ 
*/
+/* $Id: formatted_print.c,v 1.82.2.1.2.16.2.6 2008/06/25 10:16:52 davidc Exp $ 
*/
 
 #include <math.h>                              /* modf() */
 #include "php.h"
@@ -373,22 +373,26 @@
 static char *
 php_formatted_print(int ht, int *len, int use_array, int format_offset 
TSRMLS_DC)
 {
-       zval ***args = NULL, **z_format;
+       zval ***args, **z_format;
        int argc, size = 240, inpos = 0, outpos = 0, temppos;
        int alignment, currarg, adjusting, argnum, width, precision;
        char *format, *result, padding;
        int always_sign;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) 
== FAILURE) {
-               return;
-       }
+       argc = ZEND_NUM_ARGS();
 
        /* verify the number of args */
        if ((use_array && argc != (2 + format_offset)) 
                        || (!use_array && argc < (1 + format_offset))) {
                WRONG_PARAM_COUNT_WITH_RETVAL(NULL);
        }
+       args = (zval ***)safe_emalloc(argc, sizeof(zval *), 0);
 
+       if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
+               efree(args);
+               WRONG_PARAM_COUNT_WITH_RETVAL(NULL);
+       }
+       
        if (use_array) {
                int i = 1;
                zval ***newargs;
@@ -686,7 +690,6 @@
        if ((result=php_formatted_print(ht, &len, 1, 0 TSRMLS_CC))==NULL) {
                RETURN_FALSE;
        }
-
        RETVAL_STRINGL(result, len, 0);
 }
 /* }}} */
@@ -728,17 +731,18 @@
 PHP_FUNCTION(fprintf)
 {
        php_stream *stream;
-       zval **arg1 = NULL;
-       zval **args = NULL;
-       int num_args;
+       zval **arg1;
        char *result;
-       zval **format;
        int len;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z+", &arg1, 
&args) == FAILURE) {
-               return;
+       
+       if (ZEND_NUM_ARGS() < 2) {
+               WRONG_PARAM_COUNT;
        }
-
+       
+       if (zend_get_parameters_ex(1, &arg1)==FAILURE) {
+               RETURN_FALSE;
+       }
+       
        php_stream_from_zval(stream, arg1);
 
        if ((result=php_formatted_print(ht, &len, 0, 1 TSRMLS_CC))==NULL) {
@@ -760,22 +764,14 @@
        php_stream *stream;
        zval **arg1;
        char *result;
-       int num_args, len;
+       int len;
        
-       /**
-        * Here's the deal, I extract the first resource, it's 
-        * a ressource, then a string and then an array. In theory
-        * the parsing should be "rsa" however, if I do so, the 
-        * Argument number checking in php_formatted_print fails.
-        * I am therefore leaving this check here so I do not break
-        * php_formatted_print
-        */
        if (ZEND_NUM_ARGS() != 3) {
                WRONG_PARAM_COUNT;
        }
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z+", &arg1, 
&num_args) == FAILURE) {
-               return;
+       if (zend_get_parameters_ex(1, &arg1)==FAILURE) {
+               RETURN_FALSE;
        }
        
        php_stream_from_zval(stream, arg1);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to