/** @file\r
Library used for sorting routines.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
**/\r
\r
#include <Uefi.h>\r
+#include <ShellBase.h>\r
\r
#include <Protocol/UnicodeCollation.h>\r
#include <Protocol/DevicePath.h>\r
-#include <Protocol/DevicePathToText.h>\r
\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/SortLib.h>\r
+#include <Library/DevicePathLib.h>\r
\r
-STATIC EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;\r
STATIC EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation = NULL;\r
\r
\r
if Count is < 2 then perform no action.\r
if Size is < 1 then perform no action.\r
\r
- @param[in,out] BufferToSort on call a Buffer of (possibly sorted) elements\r
- on return a buffer of sorted elements\r
- @param[in] Count the number of elements in the buffer to sort\r
- @param[in] ElementSize Size of an element in bytes\r
- @param[in] CompareFunction The function to call to perform the comparison\r
- of any 2 elements\r
- @param[in] Buffer Buffer of size ElementSize for use in swapping\r
+ @param[in, out] BufferToSort on call a Buffer of (possibly sorted) elements\r
+ on return a buffer of sorted elements\r
+ @param[in] Count the number of elements in the buffer to sort\r
+ @param[in] ElementSize Size of an element in bytes\r
+ @param[in] CompareFunction The function to call to perform the comparison\r
+ of any 2 elements\r
+ @param[in] Buffer Buffer of size ElementSize for use in swapping\r
**/\r
VOID\r
EFIAPI\r
if Count is < 2 then perform no action.\r
if Size is < 1 then perform no action.\r
\r
- @param[in,out] BufferToSort on call a Buffer of (possibly sorted) elements\r
- on return a buffer of sorted elements\r
- @param[in] Count the number of elements in the buffer to sort\r
- @param[in] ElementSize Size of an element in bytes\r
- @param[in] CompareFunction The function to call to perform the comparison\r
- of any 2 elements\r
+ @param[in, out] BufferToSort on call a Buffer of (possibly sorted) elements\r
+ on return a buffer of sorted elements\r
+ @param[in] Count the number of elements in the buffer to sort\r
+ @param[in] ElementSize Size of an element in bytes\r
+ @param[in] CompareFunction The function to call to perform the comparison\r
+ of any 2 elements\r
**/\r
VOID\r
EFIAPI\r
ASSERT(BufferToSort != NULL);\r
ASSERT(CompareFunction != NULL);\r
\r
- Buffer = AllocatePool(ElementSize);\r
+ Buffer = AllocateZeroPool(ElementSize);\r
ASSERT(Buffer != NULL);\r
\r
QuickSortWorker(\r
return 1;\r
}\r
\r
- if (mDevicePathToText == NULL) {\r
- Status = gBS->LocateProtocol(\r
- &gEfiDevicePathToTextProtocolGuid,\r
- NULL,\r
- (VOID**)&mDevicePathToText);\r
-\r
- ASSERT_EFI_ERROR(Status);\r
- }\r
-\r
if (mUnicodeCollation == NULL) {\r
Status = gBS->LocateProtocol(\r
&gEfiUnicodeCollation2ProtocolGuid,\r
ASSERT_EFI_ERROR(Status);\r
}\r
\r
- TextPath1 = mDevicePathToText->ConvertDevicePathToText(\r
+ TextPath1 = ConvertDevicePathToText(\r
DevicePath1,\r
FALSE,\r
FALSE);\r
\r
- TextPath2 = mDevicePathToText->ConvertDevicePathToText(\r
+ TextPath2 = ConvertDevicePathToText(\r
DevicePath2,\r
FALSE,\r
FALSE);\r
\r
- RetVal = mUnicodeCollation->StriColl(\r
- mUnicodeCollation,\r
- TextPath1,\r
- TextPath2);\r
+ if (TextPath1 == NULL) {\r
+ RetVal = -1;\r
+ } else if (TextPath2 == NULL) {\r
+ RetVal = 1;\r
+ } else {\r
+ RetVal = mUnicodeCollation->StriColl(\r
+ mUnicodeCollation,\r
+ TextPath1,\r
+ TextPath2);\r
+ }\r
\r
- FreePool(TextPath1);\r
- FreePool(TextPath2);\r
+ SHELL_FREE_NON_NULL(TextPath1);\r
+ SHELL_FREE_NON_NULL(TextPath2);\r
\r
return (RetVal);\r
}\r