X-Git-Url: https://code.delx.au/refind/blobdiff_plain/6f26706bb54004d3b435c51f44fa17e996d82c68..0d5abdda4c44431486484d4f5d3627967e005210:/refind/mystrings.c diff --git a/refind/mystrings.c b/refind/mystrings.c index a5c5823..75e2d89 100644 --- a/refind/mystrings.c +++ b/refind/mystrings.c @@ -267,6 +267,19 @@ CHAR16 *FindNumbers(IN CHAR16 *InString) { return (Found); } // CHAR16 *FindNumbers() +// Returns the number of characters that are in common between +// String1 and String2 before they diverge. For instance, if +// String1 is "FooBar" and String2 is "FoodiesBar", this function +// will return "3", since they both start with "Foo". +UINTN NumCharsInCommon(IN CHAR16* String1, IN CHAR16* String2) { + UINTN Count = 0; + if ((String1 == NULL) || (String2 == NULL)) + return 0; + while ((String1[Count] != L'\0') && (String2[Count] != L'\0') && (String1[Count] == String2[Count])) + Count++; + return Count; +} // UINTN NumCharsInCommon() + // Find the #Index element (numbered from 0) in a comma-delimited string // of elements. // Returns the found element, or NULL if Index is out of range or InString @@ -456,3 +469,15 @@ EFI_GUID StringAsGuid(CHAR16 * InString) { return Guid; } // EFI_GUID StringAsGuid() + +// Delete the STRING_LIST pointed to by *StringList. +VOID DeleteStringList(STRING_LIST *StringList) { + STRING_LIST *Current = StringList, *Previous; + + while (Current != NULL) { + MyFreePool(Current->Value); + Previous = Current; + Current = Current->Next; + MyFreePool(Previous); + } +} // VOID DeleteStringList()