MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / getUnpackedLength

Method getUnpackedLength

src/jrd/sqz.cpp:417–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417ULONG Compressor::getUnpackedLength(ULONG inLength, const UCHAR* input)
418{
419/**************************************
420 *
421 * Calculate the unpacked length of the input compressed string.
422 *
423 **************************************/
424 const auto end = input + inLength;
425 ULONG result = 0;
426
427 while (input < end)
428 {
429 const int length = (signed char) *input++;
430
431 if (length < 0)
432 {
433 auto zipLength = (unsigned) -length;
434
435 if (length == -1)
436 {
437 zipLength = get_short(input);
438 input += sizeof(USHORT);
439 }
440 else if (length == -2)
441 {
442 zipLength = get_long(input);
443 input += sizeof(ULONG);
444 }
445
446 if (input >= end)
447 return 0; // decompression error
448
449 input++;
450 result += zipLength;
451 }
452 else
453 {
454 result += length;
455 input += length;
456 }
457 }
458
459 return result;
460}
461
462UCHAR* Compressor::unpack(ULONG inLength, const UCHAR* input,
463 ULONG outLength, UCHAR* output)

Callers

nothing calls this directly

Calls 2

get_shortFunction · 0.85
get_longFunction · 0.50

Tested by

no test coverage detected