Advance the current position (read in new data if needed).\r
Delete outdated string info. Find a match string for current position.\r
\r
+ @retval TRUE The operation was successful.\r
+ @retval FALSE The operation failed due to insufficient memory.\r
**/\r
-VOID\r
+BOOLEAN\r
EFIAPI\r
GetNextMatch (\r
VOID\r
mPos++;\r
if (mPos == WNDSIZ * 2) {\r
Temp = AllocateZeroPool (WNDSIZ + MAXMATCH);\r
+ if (Temp == NULL) {\r
+ return (FALSE);\r
+ }\r
CopyMem (Temp, &mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
CopyMem (&mText[0], Temp, WNDSIZ + MAXMATCH);\r
FreePool (Temp);\r
\r
DeleteNode ();\r
InsertNode ();\r
+\r
+ return (TRUE);\r
}\r
\r
/**\r
while (mRemainder > 0) {\r
LastMatchLen = mMatchLen;\r
LastMatchPos = mMatchPos;\r
- GetNextMatch ();\r
+ if (!GetNextMatch ()) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
if (mMatchLen > mRemainder) {\r
mMatchLen = mRemainder;\r
}\r
(mPos - LastMatchPos - 2) & (WNDSIZ - 1));\r
LastMatchLen--;\r
while (LastMatchLen > 0) {\r
- GetNextMatch ();\r
+ if (!GetNextMatch ()) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
LastMatchLen--;\r
}\r
\r
\r
HufEncodeEnd ();\r
FreeMemory ();\r
- return EFI_SUCCESS;\r
+ return (Status);\r
}\r
\r
/**\r
The compression routine.\r
\r
- @param[in] SrcBuffer The buffer containing the source data.\r
- @param[in] SrcSize The number of bytes in SrcBuffer.\r
- @param[in] DstBuffer The buffer to put the compressed image in.\r
- @param[in,out] DstSize On input the size (in bytes) of DstBuffer, on\r
+ @param[in] SrcBuffer The buffer containing the source data.\r
+ @param[in] SrcSize The number of bytes in SrcBuffer.\r
+ @param[in] DstBuffer The buffer to put the compressed image in.\r
+ @param[in, out] DstSize On input the size (in bytes) of DstBuffer, on\r
return the number of bytes placed in DstBuffer.\r
\r
@retval EFI_SUCCESS The compression was sucessful.\r