//---------------------------------------------------------------------- // Decodes all valid hex encoded bytes at the head of the // StringExtractor, limited by dst_len. // // Returns the number of bytes successfully decoded //---------------------------------------------------------------------- size_t StringExtractor::GetHexBytesAvail(llvm::MutableArrayRef<uint8_t> dest) { size_t bytes_extracted = 0; while (!dest.empty()) { int decode = DecodeHexU8(); if (decode == -1) break; dest[0] = (uint8_t)decode; dest = dest.drop_front(); ++bytes_extracted; } return bytes_extracted; }
size_t StringExtractor::GetHexBytes(llvm::MutableArrayRef<uint8_t> dest, uint8_t fail_fill_value) { size_t bytes_extracted = 0; while (!dest.empty() && GetBytesLeft() > 0) { dest[0] = GetHexU8(fail_fill_value); if (!IsGood()) break; ++bytes_extracted; dest = dest.drop_front(); } if (!dest.empty()) ::memset(dest.data(), fail_fill_value, dest.size()); return bytes_extracted; }