diff options
author | Nikita Popov <nikic@php.net> | 2014-05-28 18:34:35 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2014-05-28 18:34:35 +0200 |
commit | 3f27d707d2b699e9266ead73605b8191226e5439 (patch) | |
tree | 69441c887fb3fedcbd973351ebfa20054b410b49 | |
parent | 0987d19712e0934870932394ec41e77ea6a2bfc8 (diff) | |
download | php-git-3f27d707d2b699e9266ead73605b8191226e5439.tar.gz |
Use zend_long_to_str in curl
Also use STR_ADDREF instead of maintaining a numeric_key flag.
-rw-r--r-- | ext/curl/interface.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 41c19eab02..b45e7efc83 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); |