beautypg.com

Intel Extensible Firmware Interface User Manual

Page 979

background image

Compression Source Code

Version 1.10

12/01/02

H-15

mParent[s] = mParent[r];
mParent[r] = NIL;
mNext[r] = mAvail;
mAvail = r;
}

STATIC
VOID
GetNextMatch ()
/*++

Routine Description:

Advance the current position (read in new data if needed).
Delete outdated string info. Find a match string for current position.

Arguments: (VOID)

Returns: (VOID)

--*/
{
INT32 n;

mRemainder--;
if (++mPos == WNDSIZ * 2) {
memmove(&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH);
n = FreadCrc(&mText[WNDSIZ + MAXMATCH], WNDSIZ);
mRemainder += n;
mPos = WNDSIZ;
}
DeleteNode();
InsertNode();
}

STATIC
EFI_STATUS
Encode ()
/*++

Routine Description:

The main controlling routine for compression process.

Arguments: (VOID)

Returns:

EFI_SUCCESS - The compression is successful
EFI_OUT_0F_RESOURCES - Not enough memory for compression process

--*/
{
EFI_STATUS Status;
INT32 LastMatchLen;
NODE LastMatchPos;

Status = AllocateMemory();
if (EFI_ERROR(Status)) {
FreeMemory();