Compares up to a specified length the contents of two Null-terminated Unicode strings, and returns the difference between the first mismatched Unicode characters. This function compares the Null-terminated Unicode string FirstString to the Null-terminated Unicode string SecondString. At most, Length Unicode characters will be compared. If Length is 0, then 0 is returned. If FirstS
| 321 | |
| 322 | **/ |
| 323 | INTN |
| 324 | EFIAPI |
| 325 | StrnCmp ( |
| 326 | IN CONST CHAR16 *FirstString, |
| 327 | IN CONST CHAR16 *SecondString, |
| 328 | IN UINTN Length |
| 329 | ) |
| 330 | { |
| 331 | if (Length == 0) { |
| 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | // |
| 336 | // ASSERT both strings are less long than PcdMaximumUnicodeStringLength. |
| 337 | // Length tests are performed inside StrLen(). |
| 338 | // |
| 339 | ASSERT (StrSize (FirstString) != 0); |
| 340 | ASSERT (StrSize (SecondString) != 0); |
| 341 | |
| 342 | // if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) { |
| 343 | // ASSERT (Length <= PcdGet32 (PcdMaximumUnicodeStringLength)); |
| 344 | if (Length > 100000000ull) { |
| 345 | Length = 100000000ull; |
| 346 | } |
| 347 | |
| 348 | while ((*FirstString != L'\0') && |
| 349 | (*SecondString != L'\0') && |
| 350 | (*FirstString == *SecondString) && |
| 351 | (Length > 1)) { |
| 352 | FirstString++; |
| 353 | SecondString++; |
| 354 | Length--; |
| 355 | } |
| 356 | |
| 357 | return *FirstString - *SecondString; |
| 358 | } |
| 359 | |
| 360 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES |
| 361 |