]> granicus.if.org Git - php/commitdiff
Use zend_long_to_str in curl
authorNikita Popov <nikic@php.net>
Wed, 28 May 2014 16:34:35 +0000 (18:34 +0200)
committerNikita Popov <nikic@php.net>
Wed, 28 May 2014 16:34:35 +0000 (18:34 +0200)
Also use STR_ADDREF instead of maintaining a numeric_key flag.

ext/curl/interface.c

index 41c19eab023171d4dfbe69f5df64e6dd6b80cf01..b45e7efc8398101d1a540767aa9c0840ee421257 100644 (file)
@@ -2473,15 +2473,12 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
                                }
 
                                ZEND_HASH_FOREACH_KEY_VAL(postfields, num_key, string_key, current) {
-                                       char  *postval;
-                                       int    numeric_key;
+                                       char *postval;
                                        /* Pretend we have a string_key here */
                                        if (!string_key) {
-                                               string_key = STR_ALLOC(MAX_LENGTH_OF_LONG, 0);
-                                               string_key->len = snprintf(string_key->val, string_key->len, "%ld", num_key);
-                                               numeric_key = 1;
+                                               string_key = zend_long_to_str(num_key);
                                        } else {
-                                               numeric_key = 0;
+                                               STR_ADDREF(string_key);
                                        }
 
                                        if (Z_TYPE_P(current) == IS_OBJECT &&
@@ -2517,9 +2514,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
                                                                                        CURLFORM_END);
                                                }
 
-                                               if (numeric_key) {
-                                                       STR_RELEASE(string_key);
-                                               }
+                                               STR_RELEASE(string_key);
                                                continue;
                                        }
 
@@ -2569,10 +2564,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
                                                                                         CURLFORM_END);
                                        }
 
-                                       if (numeric_key) {
-                                               STR_RELEASE(string_key);
-                                       }
-
+                                       STR_RELEASE(string_key);
                                } ZEND_HASH_FOREACH_END();
 
                                SAVE_CURL_ERROR(ch, error);