| 220 | } |
| 221 | |
| 222 | __attribute__((unused)) static int UnpackInteger(const void *from, |
| 223 | uint32_t length, |
| 224 | bool unsigned_flag, void *to) { |
| 225 | if (from == nullptr || length < 2) { |
| 226 | return -1; |
| 227 | } |
| 228 | const uchar *ufrom = (uchar *)from; // NOLINT |
| 229 | uchar *uto = (uchar *)to; // NOLINT |
| 230 | const int sign_byte = ufrom[0]; |
| 231 | if (unsigned_flag) { |
| 232 | uto[length - 1] = sign_byte; |
| 233 | } else { |
| 234 | uto[length - 1] = |
| 235 | static_cast<char>(sign_byte ^ 128); // Reverse the sign bit. |
| 236 | } |
| 237 | for (uint32_t i = 0, j = length - 1; i < length - 1; ++i, --j) |
| 238 | uto[i] = ufrom[j]; |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | __attribute__((unused)) static int UnpackFloatingPoint( |
| 243 | const void *src, const size_t size, const int exp_digit, |