\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
\r
- @param Str Tracks the allocated pool, size in use, and amount of pool\r
- allocated.\r
+ @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r
@param fmt The format string\r
-\r
- @param ... Variable argument list.\r
+ @param ... The data will be printed.\r
\r
@return Allocated buffer with the formatted string printed in it.\r
- The caller must free the allocated buffer. The buffer\r
- allocation is not packed.\r
+ The caller must free the allocated buffer.\r
+ The buffer allocation is not packed.\r
\r
**/\r
CHAR16 *\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
\r
/**\r
- Convert Device Path to a Unicode string for printing.\r
+ Convert Vendor device path to device name.\r
\r
- @param Str The buffer holding the output string.\r
- This buffer contains the length of the\r
- string and the maixmum length reserved\r
- for the string buffer.\r
- @param DevPath The device path.\r
+ @param Str The buffer store device name\r
+ @param DevPath Pointer to vendor device path\r
\r
**/\r
VOID\r
//\r
DevPathNode = NextDevicePathNode (DevPathNode);\r
}\r
- //\r
- // Shrink pool used for string allocation\r
- //\r
- FreePool (DevPath);\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
}\r
-\r
-/**\r
- Function creates a device path data structure that identically matches the\r
- device path passed in.\r
-\r
- @param DevPath A pointer to a device path data structure.\r
-\r
- @return The new copy of DevPath is created to identically match the input.\r
- @return Otherwise, NULL is returned.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-LibDuplicateDevicePathInstance (\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
- )\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *NewDevPath;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r
- EFI_DEVICE_PATH_PROTOCOL *Temp;\r
- UINTN Size;\r
-\r
- //\r
- // get the size of an instance from the input\r
- //\r
- Temp = DevPath;\r
- DevicePathInst = GetNextDevicePathInstance (&Temp, &Size);\r
-\r
- //\r
- // Make a copy\r
- //\r
- NewDevPath = NULL;\r
- if (Size != 0) {\r
- NewDevPath = AllocateZeroPool (Size);\r
- ASSERT (NewDevPath != NULL);\r
- }\r
-\r
- if (NewDevPath != NULL) {\r
- CopyMem (NewDevPath, DevicePathInst, Size);\r
- }\r
-\r
- return NewDevPath;\r
-}\r