]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update to use ReallocatePool() from BaseMemoryLib
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 22 Nov 2008 00:52:53 +0000 (00:52 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 22 Nov 2008 00:52:53 +0000 (00:52 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6678 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c

index 67052b20b3a58c5cea773727ca7e1b5648f362f7..746c27180f665153ada82cf69ed0d7a9c3031bc7 100644 (file)
@@ -1749,8 +1749,6 @@ ConSplitterGrowBuffer (
   IN OUT  VOID                        **Buffer\r
   )\r
 {\r
-  UINTN NewSize;\r
-  UINTN OldSize;\r
   VOID  *Ptr;\r
 \r
   //\r
@@ -1758,23 +1756,16 @@ ConSplitterGrowBuffer (
   // copy the old buffer's content to the new-size buffer,\r
   // then free the old buffer.\r
   //\r
-  OldSize = *Count * SizeOfCount;\r
   *Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT;\r
-  NewSize = *Count * SizeOfCount;\r
-\r
-  Ptr     = AllocateZeroPool (NewSize);\r
+  Ptr = ReallocatePool (\r
+          SizeOfCount * ((*Count) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT), \r
+          SizeOfCount * (*Count),\r
+          *Buffer\r
+          );\r
   if (Ptr == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-\r
-  CopyMem (Ptr, *Buffer, OldSize);\r
-\r
-  if (*Buffer != NULL) {\r
-    FreePool (*Buffer);\r
-  }\r
-\r
   *Buffer = Ptr;\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
index a9f6afcf4a177f58778e41bfbc8eed1ceee9cf10..5de21b1f9d9b954bf2eebac25c0d986d88fcbfe7 100644 (file)
@@ -14,41 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "DevicePath.h"\r
 \r
-/**\r
-  Adjusts the size of a previously allocated buffer.\r
-\r
-  @param OldPool         A pointer to the buffer whose size is being adjusted.\r
-  @param OldSize         The size of the current buffer.\r
-  @param NewSize         The size of the new buffer.\r
-\r
-  @return A pointer to the new buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-ReallocatePool (\r
-  IN VOID                 *OldPool,\r
-  IN UINTN                OldSize,\r
-  IN UINTN                NewSize\r
-  )\r
-{\r
-  VOID  *NewPool;\r
-\r
-  NewPool = NULL;\r
-  if (NewSize != 0) {\r
-    NewPool = AllocateZeroPool (NewSize);\r
-  }\r
-\r
-  if (OldPool != NULL) {\r
-    if (NewPool != NULL) {\r
-      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
-    }\r
-\r
-    FreePool (OldPool);\r
-  }\r
-\r
-  return NewPool;\r
-}\r
-\r
 /**\r
   Concatenates a formatted unicode string to allocated pool. The caller must\r
   free the resulting buffer.\r
@@ -90,9 +55,9 @@ CatPrint (
     Size = StrSize (AppendStr) - sizeof (UINT16);\r
     Size = Size + StrSize (Str->Str);\r
     Str->Str = ReallocatePool (\r
-                Str->Str,\r
                 StrSize (Str->Str),\r
-                Size\r
+                Size,\r
+                Str->Str\r
                 );\r
     ASSERT (Str->Str != NULL);\r
   }\r
@@ -1752,7 +1717,7 @@ ConvertDeviceNodeToText (
   // Shrink pool used for string allocation\r
   //\r
   NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
-  Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
+  Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
   ASSERT (Str.Str != NULL);\r
   Str.Str[Str.Len] = 0;\r
   return Str.Str;\r
@@ -1841,7 +1806,7 @@ ConvertDevicePathToText (
   }\r
 \r
   NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
-  Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
+  Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
   ASSERT (Str.Str != NULL);\r
   Str.Str[Str.Len] = 0;\r
   return Str.Str;\r
index 037c8cc4f387070d33cbf2d52b5ed423bb7b606b..ee5f1140dcee06d1d3e37c3f89a6a327a2b45852 100644 (file)
@@ -270,44 +270,6 @@ OutputConfigBody (
 \r
 }\r
 \r
-\r
-/**\r
-  Adjusts the size of a previously allocated buffer.\r
-\r
-\r
-  @param OldPool         A pointer to the buffer whose size is being adjusted.\r
-  @param OldSize         The size of the current buffer.\r
-  @param NewSize         The size of the new buffer.\r
-\r
-  @return The new buffer allocated.\r
-\r
-**/\r
-VOID *\r
-ReallocatePool (\r
-  IN VOID                          *OldPool,\r
-  IN UINTN                         OldSize,\r
-  IN UINTN                         NewSize\r
-  )\r
-{\r
-  VOID  *NewPool;\r
-\r
-  NewPool = NULL;\r
-  if (NewSize != 0) {\r
-    NewPool = AllocateZeroPool (NewSize);\r
-  }\r
-\r
-  if (OldPool != NULL) {\r
-    if (NewPool != NULL) {\r
-      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
-    }\r
-\r
-    FreePool (OldPool);\r
-  }\r
-\r
-  return NewPool;\r
-}\r
-\r
-\r
 /**\r
   Append a string to a multi-string format.\r
 \r
@@ -346,9 +308,9 @@ AppendToMultiString (
   if (MultiStringSize + AppendStringSize > MAX_STRING_LENGTH ||\r
       MultiStringSize > MAX_STRING_LENGTH) {\r
     *MultiString = (EFI_STRING) ReallocatePool (\r
-                                  (VOID *) (*MultiString),\r
                                   MultiStringSize,\r
-                                  MultiStringSize + AppendStringSize\r
+                                  MultiStringSize + AppendStringSize,\r
+                                  (VOID *) (*MultiString)\r
                                   );\r
   }\r
 \r