com php-src: Use zend_long_to_str in curl: ext/cu rl/interface.c
| From: | Nikita Popov | Date: | Wed, 28 May 2014 16:34:35 +0000 |
| Subject: | com php-src: Use zend_long_to_str in curl: ext/cu rl/interface.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78619@lists.php.net to get a copy of this message | ||
Commit: 3f27d707d2b699e9266ead73605b8191226e5439
Author: Nikita Popov <nikic@php.net> Wed, 28 May 2014 18:34:35 +0200
Parents: 0987d19712e0934870932394ec41e77ea6a2bfc8
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3f27d707d2b699e9266ead73605b8191226e5439
Log:
Use zend_long_to_str in curl
Also use STR_ADDREF instead of maintaining a numeric_key flag.
Changed paths:
M ext/curl/interface.c
Diff:
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 41c19ea..b45e7ef 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -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);