THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
\r
- Module Name: MemoryAllocationLib.c\r
-\r
**/\r
\r
\r
+#include <PiDxe.h>\r
+\r
+\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#include "MemoryAllocationLibInternals.h"\r
+\r
/**\r
Allocates one or more 4KB pages of a certain memory type.\r
\r
return NULL;\r
}\r
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;\r
- UnalignedPages = EFI_SIZE_TO_PAGES ((UINTN) Memory - AlignedMemory);\r
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);\r
if (UnalignedPages > 0) {\r
//\r
// Free first unaligned page(s).\r
Status = gBS->FreePool (RawAddress);\r
ASSERT_EFI_ERROR (Status);\r
}\r
+\r
+\r
+VOID\r
+EFIAPI\r
+SafeFreePool (\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ if (Buffer != NULL) {\r
+ FreePool (Buffer);\r
+ Buffer = NULL;\r
+ }\r
+}\r
+\r