*outptr = NULL;
*outlen = 0;
- if(0 == insize)
+ if(!insize)
insize = strlen(indata);
- base64data = output = malloc(insize*4/3+4);
- if(NULL == output)
+ base64data = output = malloc(insize * 4 / 3 + 4);
+ if(!output)
return CURLE_OUT_OF_MEMORY;
/*
table64[obuf[0]],
table64[obuf[1]]);
break;
+
case 2: /* two bytes read */
snprintf(output, 5, "%c%c%c=",
table64[obuf[0]],
table64[obuf[1]],
table64[obuf[2]]);
break;
+
default:
snprintf(output, 5, "%c%c%c%c",
table64[obuf[0]],
}
output += 4;
}
+
+ /* Zero terminate */
*output = '\0';
- *outptr = base64data; /* return pointer to new data, allocated memory */
+
+ /* Return the pointer to the new data (allocated memory) */
+ *outptr = base64data;
free(convbuf);
- *outlen = strlen(base64data); /* return the length of the new data */
+ /* Return the length of the new data */
+ *outlen = strlen(base64data);
return CURLE_OK;
}
{
return base64_encode(base64url, data, inputbuff, insize, outptr, outlen);
}
-/* ---- End of Base64 Encoding ---- */