size_t *stralloc, /* allocated size */
char base64) /* 1 if base64 encoded */
{
+ union {
+ unsigned char * as_uchar;
+ char * as_char;
+ } buf64;
+
size_t len = strlen(buffer);
size_t needed_len = len + *stringlen + 1;
- char *buf64=NULL;
+
+ buf64.as_char = NULL;
if(base64) {
/* decode the given buffer first */
- len = Curl_base64_decode(buffer, (unsigned char**)&buf64); /* updated len */
- buffer = buf64;
+ len = Curl_base64_decode(buffer, &buf64.as_uchar); /* updated len */
+ buffer = buf64.as_char;
needed_len = len + *stringlen + 1; /* recalculate */
}
*stralloc = newsize;
}
else {
- if(buf64)
- free(buf64);
+ if(buf64.as_char)
+ free(buf64.as_char);
return NULL;
}
}
*stringlen += len;
string[*stringlen]=0;
- if(buf64)
- free(buf64);
+ if(buf64.as_char)
+ free(buf64.as_char);
return string;
}