summaryrefslogtreecommitdiff
path: root/lib/cookie.c
diff options
context:
space:
mode:
authorMarcel Raad <Marcel.Raad@teamviewer.com>2019-05-11 21:42:48 +0200
committerMarcel Raad <Marcel.Raad@teamviewer.com>2019-05-20 08:51:11 +0200
commit10db3ef21eef1c7a1727579952a81ced2f4afc8b (patch)
tree57129a847b5913959063a60290201b1f52482fee /lib/cookie.c
parent27af2ec219244bef24e6d11649d41aad3668da45 (diff)
downloadcurl-10db3ef21eef1c7a1727579952a81ced2f4afc8b.tar.gz
lib: reduce variable scopes
Fixes Codacy/CppCheck warnings. Closes https://github.com/curl/curl/pull/3872
Diffstat (limited to 'lib/cookie.c')
-rw-r--r--lib/cookie.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index 15bb28166..05ce62193 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -1509,10 +1509,6 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
struct Cookie *co;
FILE *out;
bool use_stdout = FALSE;
- char *format_ptr;
- unsigned int i;
- unsigned int j;
- struct Cookie **array;
if(!c)
/* no cookie engine alive */
@@ -1539,6 +1535,10 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
out);
if(c->numcookies) {
+ unsigned int i;
+ unsigned int j;
+ struct Cookie **array;
+
array = malloc(sizeof(struct Cookie *) * c->numcookies);
if(!array) {
if(!use_stdout)
@@ -1558,7 +1558,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
qsort(array, c->numcookies, sizeof(struct Cookie *), cookie_sort_ct);
for(i = 0; i < j; i++) {
- format_ptr = get_netscape_format(array[i]);
+ char *format_ptr = get_netscape_format(array[i]);
if(format_ptr == NULL) {
fprintf(out, "#\n# Fatal libcurl error\n");
free(array);