MCPcopy Create free account
hub / github.com/catboost/catboost / Base64DecodeUneven

Function Base64DecodeUneven

library/cpp/string_utils/base64/base64.cpp:271–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271size_t Base64DecodeUneven(void* dst, const TStringBuf s) {
272 const size_t tailSize = s.length() % 4;
273 if (tailSize == 0) {
274 return Base64Decode(dst, s.begin(), s.end());
275 }
276
277 // divide s into even part and tail and decode in two step, to avoid memory allocation
278 char tail[4] = {'=', '=', '=', '='};
279 memcpy(tail, s.end() - tailSize, tailSize);
280 size_t decodedEven = s.length() > 4 ? Base64Decode(dst, s.begin(), s.end() - tailSize) : 0;
281 // there should not be tail of size 1 it's incorrect for 8-bit bytes
282 size_t decodedTail = tailSize != 1 ? Base64Decode(static_cast<char*>(dst) + decodedEven, tail, tail + 4) : 0;
283 return decodedEven + decodedTail;
284}
285
286TString Base64DecodeUneven(const TStringBuf s) {
287 TString ret;

Callers 4

Y_UNIT_TESTFunction · 0.85
Y_UNIT_TESTFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85

Calls 8

Base64DecodeBufSizeFunction · 0.85
Base64DecodeFunction · 0.70
lengthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
resizeMethod · 0.45

Tested by 1