MCPcopy Create free account
hub / github.com/apache/impala / Base64DecodeBufLen

Function Base64DecodeBufLen

be/src/util/coding-util.cc:196–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196bool Base64DecodeBufLen(const char* in, int64_t in_len, int64_t* out_max) {
197 // Base64 decoding turns every 4 characters into 3 bytes. If the last character of the
198 // encoded string is '=', that character (which represents 6 bits) and the last two bits
199 // of the previous character is ignored, for a total of 8 ignored bits, therefore
200 // producing one fewer byte of output. This is repeated if the second-to-last character
201 // is '='. One more byte must be allocated to account for Base64Decode's null-padding
202 // of its output.
203 if (UNLIKELY(in_len == 0)) {
204 *out_max = 0;
205 return true;
206 }
207 if (UNLIKELY((in_len & 3) != 0)) return false;
208 *out_max = 1 + 3 * (in_len / 4);
209 DCHECK_GE(in_len, 1);
210 if (in[in_len - 1] == '=') {
211 --(*out_max);
212 DCHECK_GE(in_len, 2);
213 if (in[in_len - 2] == '=') {
214 --(*out_max);
215 }
216 }
217 return true;
218}
219
220bool Base64Decode(const char* in, int64_t in_len, int64_t out_max, char* out,
221 unsigned* out_len) {

Callers 4

Base64DecodeMethod · 0.85
WriteSlotMethod · 0.85
TestBase64Function · 0.85
TESTFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestBase64Function · 0.68
TESTFunction · 0.68