summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2008-11-22 00:52:53 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2008-11-22 00:52:53 +0000
commitc46484952ad23fca742f8e6add49d78bda702d58 (patch)
treeec00b0ca402f7e620e4d01ff9bbf300f04548b25
parentd777486198d8ec66e2f461a641d505f4063e1e5e (diff)
downloadedk2-c46484952ad23fca742f8e6add49d78bda702d58.tar.gz
edk2-c46484952ad23fca742f8e6add49d78bda702d58.tar.bz2
edk2-c46484952ad23fca742f8e6add49d78bda702d58.zip
Update to use ReallocatePool() from BaseMemoryLib
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6678 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c19
-rw-r--r--MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c43
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c42
3 files changed, 11 insertions, 93 deletions
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
index 67052b20b3..746c27180f 100644
--- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
+++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
@@ -1749,8 +1749,6 @@ ConSplitterGrowBuffer (
IN OUT VOID **Buffer
)
{
- UINTN NewSize;
- UINTN OldSize;
VOID *Ptr;
//
@@ -1758,23 +1756,16 @@ ConSplitterGrowBuffer (
// copy the old buffer's content to the new-size buffer,
// then free the old buffer.
//
- OldSize = *Count * SizeOfCount;
*Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT;
- NewSize = *Count * SizeOfCount;
-
- Ptr = AllocateZeroPool (NewSize);
+ Ptr = ReallocatePool (
+ SizeOfCount * ((*Count) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT),
+ SizeOfCount * (*Count),
+ *Buffer
+ );
if (Ptr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
-
- CopyMem (Ptr, *Buffer, OldSize);
-
- if (*Buffer != NULL) {
- FreePool (*Buffer);
- }
-
*Buffer = Ptr;
-
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
index a9f6afcf4a..5de21b1f9d 100644
--- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
+++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
@@ -15,41 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "DevicePath.h"
/**
- Adjusts the size of a previously allocated buffer.
-
- @param OldPool A pointer to the buffer whose size is being adjusted.
- @param OldSize The size of the current buffer.
- @param NewSize The size of the new buffer.
-
- @return A pointer to the new buffer or NULL if allocation fails.
-
-**/
-VOID *
-ReallocatePool (
- IN VOID *OldPool,
- IN UINTN OldSize,
- IN UINTN NewSize
- )
-{
- VOID *NewPool;
-
- NewPool = NULL;
- if (NewSize != 0) {
- NewPool = AllocateZeroPool (NewSize);
- }
-
- if (OldPool != NULL) {
- if (NewPool != NULL) {
- CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
- }
-
- FreePool (OldPool);
- }
-
- return NewPool;
-}
-
-/**
Concatenates a formatted unicode string to allocated pool. The caller must
free the resulting buffer.
@@ -90,9 +55,9 @@ CatPrint (
Size = StrSize (AppendStr) - sizeof (UINT16);
Size = Size + StrSize (Str->Str);
Str->Str = ReallocatePool (
- Str->Str,
StrSize (Str->Str),
- Size
+ Size,
+ Str->Str
);
ASSERT (Str->Str != NULL);
}
@@ -1752,7 +1717,7 @@ ConvertDeviceNodeToText (
// Shrink pool used for string allocation
//
NewSize = (Str.Len + 1) * sizeof (CHAR16);
- Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);
+ Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);
ASSERT (Str.Str != NULL);
Str.Str[Str.Len] = 0;
return Str.Str;
@@ -1841,7 +1806,7 @@ ConvertDevicePathToText (
}
NewSize = (Str.Len + 1) * sizeof (CHAR16);
- Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);
+ Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);
ASSERT (Str.Str != NULL);
Str.Str[Str.Len] = 0;
return Str.Str;
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index 037c8cc4f3..ee5f1140dc 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -270,44 +270,6 @@ OutputConfigBody (
}
-
-/**
- Adjusts the size of a previously allocated buffer.
-
-
- @param OldPool A pointer to the buffer whose size is being adjusted.
- @param OldSize The size of the current buffer.
- @param NewSize The size of the new buffer.
-
- @return The new buffer allocated.
-
-**/
-VOID *
-ReallocatePool (
- IN VOID *OldPool,
- IN UINTN OldSize,
- IN UINTN NewSize
- )
-{
- VOID *NewPool;
-
- NewPool = NULL;
- if (NewSize != 0) {
- NewPool = AllocateZeroPool (NewSize);
- }
-
- if (OldPool != NULL) {
- if (NewPool != NULL) {
- CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
- }
-
- FreePool (OldPool);
- }
-
- return NewPool;
-}
-
-
/**
Append a string to a multi-string format.
@@ -346,9 +308,9 @@ AppendToMultiString (
if (MultiStringSize + AppendStringSize > MAX_STRING_LENGTH ||
MultiStringSize > MAX_STRING_LENGTH) {
*MultiString = (EFI_STRING) ReallocatePool (
- (VOID *) (*MultiString),
MultiStringSize,
- MultiStringSize + AppendStringSize
+ MultiStringSize + AppendStringSize,
+ (VOID *) (*MultiString)
);
}