MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / AsciiStrnCmp

Function AsciiStrnCmp

MdePkg/Library/BaseLib/String.c:1456–1498  ·  view source on GitHub ↗

Compares two Null-terminated ASCII strings with maximum lengths, and returns the difference between the first mismatched ASCII characters. This function compares the Null-terminated ASCII string FirstString to the Null-terminated ASCII string SecondString. At most, Length ASCII characters will be compared. If Length is 0, then 0 is returned. If FirstString is identical to SecondS

Source from the content-addressed store, hash-verified

1454
1455**/
1456INTN
1457EFIAPI
1458AsciiStrnCmp (
1459 IN CONST CHAR8 *FirstString,
1460 IN CONST CHAR8 *SecondString,
1461 IN UINTN Length
1462 )
1463{
1464 if (Length == 0) {
1465 return 0;
1466 }
1467
1468 //
1469 // ASSERT both strings are less long than PcdMaximumAsciiStringLength
1470 //
1471// ASSERT (AsciiStrSize (FirstString));
1472// ASSERT (AsciiStrSize (SecondString));
1473 if (!AsciiStrSize (FirstString) && !AsciiStrSize (SecondString)) {
1474 return 0;
1475 }
1476 if (!AsciiStrSize (FirstString)) {
1477 return -1;
1478 }
1479 if (!AsciiStrSize (SecondString)) {
1480 return 1;
1481 }
1482
1483// if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {
1484// ASSERT (Length <= PcdGet32 (PcdMaximumAsciiStringLength));
1485 if (Length > 100000000ull) {
1486 Length = 100000000ull;
1487 }
1488
1489 while ((*FirstString != '\0') &&
1490 (*SecondString != '\0') &&
1491 (*FirstString == *SecondString) &&
1492 (Length > 1)) {
1493 FirstString++;
1494 SecondString++;
1495 Length--;
1496 }
1497 return *FirstString - *SecondString;
1498}
1499
1500#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1501

Callers 15

LookupUnicodeString2Function · 0.85
AddUnicodeString2Function · 0.85
UefiLib.cFile · 0.85
KernelPatcher_64Method · 0.85
KernelPatcher_32Method · 0.85
DevTreeFixFunction · 0.85
DevTreeFixFunction · 0.85
GetFileSizeFunction · 0.85

Calls 1

AsciiStrSizeFunction · 0.85

Tested by

no test coverage detected