| 593 | } |
| 594 | |
| 595 | STATIC |
| 596 | VOID |
| 597 | Decode ( |
| 598 | SCRATCH_DATA *Sd |
| 599 | ) |
| 600 | /*++ |
| 601 | |
| 602 | Routine Description: |
| 603 | |
| 604 | Decode the source data and put the resulting data into the destination buffer. |
| 605 | |
| 606 | Arguments: |
| 607 | |
| 608 | Sd - The global scratch data |
| 609 | |
| 610 | Returns: (VOID) |
| 611 | |
| 612 | --*/ |
| 613 | { |
| 614 | UINT16 BytesRemain; |
| 615 | UINT32 DataIdx; |
| 616 | UINT16 CharC; |
| 617 | |
| 618 | BytesRemain = (UINT16) (-1); |
| 619 | |
| 620 | DataIdx = 0; |
| 621 | |
| 622 | for (;;) { |
| 623 | CharC = DecodeC (Sd); |
| 624 | if (Sd->mBadTableFlag != 0) { |
| 625 | return ; |
| 626 | } |
| 627 | |
| 628 | if (CharC < 256) { |
| 629 | // |
| 630 | // Process an Original character |
| 631 | // |
| 632 | Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC; |
| 633 | if (Sd->mOutBuf >= Sd->mOrigSize) { |
| 634 | return ; |
| 635 | } |
| 636 | |
| 637 | } else { |
| 638 | // |
| 639 | // Process a Pointer |
| 640 | // |
| 641 | CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD)); |
| 642 | |
| 643 | BytesRemain = CharC; |
| 644 | |
| 645 | DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1; |
| 646 | |
| 647 | BytesRemain--; |
| 648 | while ((INT16) (BytesRemain) >= 0) { |
| 649 | if (Sd->mOutBuf >= Sd->mOrigSize) { |
| 650 | return ; |
| 651 | } |
| 652 | if (DataIdx >= Sd->mOrigSize) { |
no test coverage detected