\r
#include "InternalBdsLib.h"\r
\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 The new buffer allocated. If allocatio failed, NULL will be returned.\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.\r
The caller must free the resulting buffer.\r
StringSize += (StrSize (Str->str) - sizeof (UINT16));\r
\r
Str->str = ReallocatePool (\r
- Str->str,\r
StrSize (Str->str),\r
- StringSize\r
+ StringSize,\r
+ Str->str\r
);\r
ASSERT (Str->str != NULL);\r
}\r
\r
Done:\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