mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-05-30 21:38:03 -04:00
base64: add base64_encode_oneshot()
Convenience function for base64_encode() + base64_encode_final(). Internally, we also add base64_encode_to_buffer() This is an internal function that encodes a multiple-of-three long input into a user allocated buffer. base64_encode() and base64_encode_oneshot() uses the new function to do the bulk of the encoding. This allows base64_encode_oneshot() to do a single allocation. This patch also adds unit tests for both base64_encode() and base64_encode_oneshot() (but _not_ for base64_encode_final()). Finally, the type of the 'data' parameter is changed to 'void*'.
This commit is contained in:
parent
4bf60d0fbc
commit
4bc8a39d6c
2 changed files with 113 additions and 16 deletions
5
base64.h
5
base64.h
|
|
@ -4,5 +4,6 @@
|
|||
#include <stddef.h>
|
||||
|
||||
char *base64_decode(const char *s, size_t *out_len);
|
||||
char *base64_encode(const uint8_t *data, size_t size);
|
||||
void base64_encode_final(const uint8_t *data, size_t size, char result[4]);
|
||||
char *base64_encode(const void *data, size_t size);
|
||||
void base64_encode_final(const void *data, size_t size, char result[4]);
|
||||
char *base64_encode_oneshot(const void *data, size_t size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue