Function of type rdb_index_field_unpack_t */
| 342 | Function of type rdb_index_field_unpack_t |
| 343 | */ |
| 344 | __attribute__((unused)) static int UnpackString(const void *src, void *dst, |
| 345 | int32_t *size) { |
| 346 | if (src == nullptr) { |
| 347 | return -1; |
| 348 | } |
| 349 | const uchar *usrc = (uchar *)src; // NOLINT |
| 350 | uchar *udst = (uchar *)dst; // NOLINT |
| 351 | const uchar *ptr; |
| 352 | size_t len = 0; |
| 353 | bool finished = false; |
| 354 | /* Decode the length-emitted encoding here */ |
| 355 | while ((ptr = Read(RDB_ESCAPE_LENGTH, &usrc))) { |
| 356 | uint32_t used_bytes = |
| 357 | CalcUnpackVariableFormat(ptr[RDB_ESCAPE_LENGTH - 1], &finished); |
| 358 | if (used_bytes == (uint32_t)-1) { |
| 359 | return -2; |
| 360 | } |
| 361 | /* |
| 362 | Now, we need to decode used_bytes of data and append them to the |
| 363 | value. |
| 364 | */ |
| 365 | memcpy(udst, ptr, used_bytes); |
| 366 | udst += used_bytes; |
| 367 | len += used_bytes; |
| 368 | if (finished) { |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | if (!finished) { |
| 373 | return -3; |
| 374 | } |
| 375 | /* Save the length */ |
| 376 | *size = len; |
| 377 | return 0; |
| 378 | } |
| 379 | |
| 380 | } // namespace codec |
| 381 | } // namespace fedb |