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

Method apply

src/jrd/sqz.cpp:517–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

515}
516
517ULONG Difference::apply(ULONG diffLength, ULONG outLength, UCHAR* const output)
518{
519/**************************************
520 *
521 * Apply a differences (delta) to a record.
522 * Return the length.
523 *
524 **************************************/
525 if (diffLength > MAX_DIFFERENCES)
526 BUGCHECK(176); // msg 176 bad difference record
527
528 auto differences = m_differences;
529 const auto end = differences + diffLength;
530 auto p = output;
531 const auto p_end = output + outLength;
532
533 while (differences < end && p < p_end)
534 {
535 const int l = (signed char) *differences++;
536
537 if (l > 0)
538 {
539 if (p + l > p_end)
540 BUGCHECK(177); // msg 177 applied differences will not fit in record
541
542 if (differences + l > end)
543 BUGCHECK(176); // msg 176 bad difference record
544
545 memcpy(p, differences, l);
546 p += l;
547 differences += l;
548 }
549 else
550 {
551 p += -l;
552 }
553 }
554
555 while (differences < end)
556 {
557 if (*differences++)
558 BUGCHECK(177); // msg 177 applied differences will not fit in record
559 }
560
561 const auto length = p - output;
562
563 if (length > outLength)
564 BUGCHECK(177); // msg 177 applied differences will not fit in record
565
566 return length;
567}
568
569ULONG Difference::makeNoDiff(ULONG length)
570{

Callers 2

VIO_dataFunction · 0.45
delete_recordFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected