add macros for base64 output len requirements
@chpe
Submitted by Christian Persch Link to original bug (#575092)
Description
g_base64_encode_step docs say:
- be written to it. Due to the way base64 encodes you will need
-
- at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
-
- non-zero state). If you enable line-breaking you will need at least:
-
- ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
It would be nice if there were some macros for this so the callers could use them when allocating the buffer, e.g.
#define G_BASE64_ENCODE_OUTPUT_BUFFER_SIZE(inputlen) ((inputlen) / 3 + 1) * 4 + 4) #define G_BASE64_ENCODE_LF_OUTPUT_BUFFER_SIZE(len) ....
and maybe same for the decoding space requirements with g_base64_decode_step.