X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FGenericBdsLib%2FDevicePath.c;h=135fa63d1a018995d57a80f652243aad6115ded7;hb=e56187913724379012649c0411668f94ac2ffd9f;hp=f420625fc920fa1518d5eeed8c14c753806863ac;hpb=1232b21473646661a4ac1ae4b7bf5113d4613e83;p=mirror_edk2.git diff --git a/MdeModulePkg/Library/GenericBdsLib/DevicePath.c b/MdeModulePkg/Library/GenericBdsLib/DevicePath.c index f420625fc9..135fa63d1a 100644 --- a/MdeModulePkg/Library/GenericBdsLib/DevicePath.c +++ b/MdeModulePkg/Library/GenericBdsLib/DevicePath.c @@ -15,55 +15,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "InternalBdsLib.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 The new buffer allocated. If allocatio failed, NULL will be returned. - -**/ -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. - @param Str Tracks the allocated pool, size in use, and amount of pool - allocated. + @param Str Tracks the allocated pool, size in use, and amount of pool allocated. @param fmt The format string - - @param ... Variable argument list. + @param ... The data will be printed. @return Allocated buffer with the formatted string printed in it. - The caller must free the allocated buffer. The buffer - allocation is not packed. + The caller must free the allocated buffer. + The buffer allocation is not packed. **/ CHAR16 * @@ -95,9 +57,9 @@ CatPrint ( StringSize += (StrSize (Str->str) - sizeof (UINT16)); Str->str = ReallocatePool ( - Str->str, StrSize (Str->str), - StringSize + StringSize, + Str->str ); ASSERT (Str->str != NULL); } @@ -208,13 +170,10 @@ DevPathController ( /** - Convert Device Path to a Unicode string for printing. + Convert Vendor device path to device name. - @param Str The buffer holding the output string. - This buffer contains the length of the - string and the maixmum length reserved - for the string buffer. - @param DevPath The device path. + @param Str The buffer store device name + @param DevPath Pointer to vendor device path **/ VOID @@ -1516,57 +1475,11 @@ DevicePathToStr ( // DevPathNode = NextDevicePathNode (DevPathNode); } - // - // Shrink pool used for string allocation - // - FreePool (DevPath); Done: 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; } - -/** - Function creates a device path data structure that identically matches the - device path passed in. - - @param DevPath A pointer to a device path data structure. - - @return The new copy of DevPath is created to identically match the input. - @return Otherwise, NULL is returned. - -**/ -EFI_DEVICE_PATH_PROTOCOL * -LibDuplicateDevicePathInstance ( - IN EFI_DEVICE_PATH_PROTOCOL *DevPath - ) -{ - EFI_DEVICE_PATH_PROTOCOL *NewDevPath; - EFI_DEVICE_PATH_PROTOCOL *DevicePathInst; - EFI_DEVICE_PATH_PROTOCOL *Temp; - UINTN Size; - - // - // get the size of an instance from the input - // - Temp = DevPath; - DevicePathInst = GetNextDevicePathInstance (&Temp, &Size); - - // - // Make a copy - // - NewDevPath = NULL; - if (Size != 0) { - NewDevPath = AllocateZeroPool (Size); - ASSERT (NewDevPath != NULL); - } - - if (NewDevPath != NULL) { - CopyMem (NewDevPath, DevicePathInst, Size); - } - - return NewDevPath; -}