]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / PeiMemoryAllocationLib / MemoryAllocationLib.c
index b3f9df74f1390cd9b83cc1c07b6b2fc5364161ef..e540e06e006348d3bf3cf1f62b40aa679a7613b0 100644 (file)
@@ -7,17 +7,14 @@
 \r
 **/\r
 \r
-\r
 #include <PiPei.h>\r
 \r
-\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PeiServicesLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/HobLib.h>\r
 \r
-\r
 /**\r
   Allocates one or more 4KB pages of a certain memory type.\r
 \r
@@ -49,7 +46,7 @@ InternalAllocatePages (
     return NULL;\r
   }\r
 \r
-  return (VOID *) (UINTN) Memory;\r
+  return (VOID *)(UINTN)Memory;\r
 }\r
 \r
 /**\r
@@ -145,7 +142,7 @@ FreePages (
   EFI_STATUS  Status;\r
 \r
   ASSERT (Pages != 0);\r
-  Status = PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+  Status = PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
@@ -190,23 +187,25 @@ InternalAllocateAlignedPages (
   if (Pages == 0) {\r
     return NULL;\r
   }\r
+\r
   if (Alignment > EFI_PAGE_SIZE) {\r
     //\r
     // Calculate the total number of pages since alignment is larger than page size.\r
     //\r
-    AlignmentMask  = Alignment - 1;\r
-    RealPages      = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
+    AlignmentMask = Alignment - 1;\r
+    RealPages     = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
     //\r
     // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
     //\r
     ASSERT (RealPages > Pages);\r
 \r
-    Status         = PeiServicesAllocatePages (MemoryType, RealPages, &Memory);\r
+    Status = PeiServicesAllocatePages (MemoryType, RealPages, &Memory);\r
     if (EFI_ERROR (Status)) {\r
       return NULL;\r
     }\r
-    AlignedMemory  = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;\r
-    UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);\r
+\r
+    AlignedMemory  = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;\r
+    UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);\r
     if (UnalignedPages > 0) {\r
       //\r
       // Free first unaligned page(s).\r
@@ -214,6 +213,7 @@ InternalAllocateAlignedPages (
       Status = PeiServicesFreePages (Memory, UnalignedPages);\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
+\r
     Memory         = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);\r
     UnalignedPages = RealPages - Pages - UnalignedPages;\r
     if (UnalignedPages > 0) {\r
@@ -231,9 +231,11 @@ InternalAllocateAlignedPages (
     if (EFI_ERROR (Status)) {\r
       return NULL;\r
     }\r
-    AlignedMemory  = (UINTN) Memory;\r
+\r
+    AlignedMemory = (UINTN)Memory;\r
   }\r
-  return (VOID *) AlignedMemory;\r
+\r
+  return (VOID *)AlignedMemory;\r
 }\r
 \r
 /**\r
@@ -350,7 +352,7 @@ FreeAlignedPages (
   EFI_STATUS  Status;\r
 \r
   ASSERT (Pages != 0);\r
-  Status = PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+  Status = PeiServicesFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
@@ -399,13 +401,14 @@ AllocatePool (
   IN UINTN  AllocationSize\r
   )\r
 {\r
-  EFI_STATUS        Status;\r
-  VOID              *Buffer;\r
+  EFI_STATUS  Status;\r
+  VOID        *Buffer;\r
 \r
   Status = PeiServicesAllocatePool (AllocationSize, &Buffer);\r
   if (EFI_ERROR (Status)) {\r
     Buffer = NULL;\r
   }\r
+\r
   return Buffer;\r
 }\r
 \r
@@ -477,6 +480,7 @@ InternalAllocateZeroPool (
   if (Memory != NULL) {\r
     Memory = ZeroMem (Memory, AllocationSize);\r
   }\r
+\r
   return Memory;\r
 }\r
 \r
@@ -505,6 +509,7 @@ AllocateZeroPool (
   if (Memory != NULL) {\r
     Memory = ZeroMem (Memory, AllocationSize);\r
   }\r
+\r
   return Memory;\r
 }\r
 \r
@@ -579,12 +584,13 @@ InternalAllocateCopyPool (
   VOID  *Memory;\r
 \r
   ASSERT (Buffer != NULL);\r
-  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
 \r
   Memory = InternalAllocatePool (PoolType, AllocationSize);\r
   if (Memory != NULL) {\r
-     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+    Memory = CopyMem (Memory, Buffer, AllocationSize);\r
   }\r
+\r
   return Memory;\r
 }\r
 \r
@@ -615,12 +621,13 @@ AllocateCopyPool (
   VOID  *Memory;\r
 \r
   ASSERT (Buffer != NULL);\r
-  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
 \r
   Memory = AllocatePool (AllocationSize);\r
   if (Memory != NULL) {\r
-     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+    Memory = CopyMem (Memory, Buffer, AllocationSize);\r
   }\r
+\r
   return Memory;\r
 }\r
 \r
@@ -711,10 +718,11 @@ InternalReallocatePool (
   VOID  *NewBuffer;\r
 \r
   NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);\r
-  if (NewBuffer != NULL && OldBuffer != NULL) {\r
+  if ((NewBuffer != NULL) && (OldBuffer != NULL)) {\r
     CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));\r
     FreePool (OldBuffer);\r
   }\r
+\r
   return NewBuffer;\r
 }\r
 \r
@@ -831,12 +839,10 @@ ReallocateReservedPool (
 VOID\r
 EFIAPI\r
 FreePool (\r
-  IN VOID   *Buffer\r
+  IN VOID  *Buffer\r
   )\r
 {\r
   //\r
   // PEI phase does not support to free pool, so leave it as NOP.\r
   //\r
 }\r
-\r
-\r