signed-off-by: andrewfish
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11887
6f19259b-4bc3-4df7-8a09-
765794883524
+ EFI_STATUS Status;\r
+\r
+ if (!gEmuThunk->Free (Buffer)) {\r
+ // The Free thunk will not free memory allocated in emulated EFI memory.\r
+ // The assmuption is this was allocated directly by EFI. We need this as some \r
+ // times protocols or EFI BootServices can return dynamically allocated buffers.\r
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
IN UINTN Alignment\r
)\r
{\r
IN UINTN Alignment\r
)\r
{\r
VOID *Memory;\r
UINTN AlignedMemory;\r
UINTN AlignmentMask;\r
VOID *Memory;\r
UINTN AlignedMemory;\r
UINTN AlignmentMask;\r
//\r
// Free first unaligned page(s).\r
//\r
//\r
// Free first unaligned page(s).\r
//\r
+ FreePages (Memory, UnalignedPages);\r
}\r
Memory = (VOID *) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
UnalignedPages = RealPages - Pages - UnalignedPages;\r
}\r
Memory = (VOID *) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
UnalignedPages = RealPages - Pages - UnalignedPages;\r
//\r
// Free last unaligned page(s).\r
//\r
//\r
// Free last unaligned page(s).\r
//\r
+ FreePages (Memory, UnalignedPages);\r
- ASSERT (Pages != 0);\r
-\r
- FreePool (Buffer);\r
+ FreePages (Buffer, Pages);\r
IN VOID *Buffer\r
)\r
{\r
IN VOID *Buffer\r
)\r
{\r
- EFI_STATUS Status;\r
- \r
+ EFI_STATUS Status;\r
+\r
if (!gEmuThunk->Free (Buffer)) {\r
// The Free thunk will not free memory allocated in emulated EFI memory.\r
// The assmuption is this was allocated directly by EFI. We need this as some \r
// times protocols or EFI BootServices can return dynamically allocated buffers.\r
if (!gEmuThunk->Free (Buffer)) {\r
// The Free thunk will not free memory allocated in emulated EFI memory.\r
// The assmuption is this was allocated directly by EFI. We need this as some \r
// times protocols or EFI BootServices can return dynamically allocated buffers.\r
- gBS->FreePool (Buffer);\r
+ Status = gBS->FreePool (Buffer);\r
+ ASSERT_EFI_ERROR (Status);\r