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

Function AsciiStrnLenS

MdePkg/Library/BaseLib/SafeString.c:1716–1746  ·  view source on GitHub ↗

Returns the length of a Null-terminated Ascii string. This function is similar as strlen_s defined in C11. @param String A pointer to a Null-terminated Ascii string. @param MaxSize The maximum number of Destination Ascii char, including terminating null char. @retval 0 If String is NULL. @retval MaxSize If there is no null character in the firs

Source from the content-addressed store, hash-verified

1714
1715**/
1716UINTN
1717EFIAPI
1718AsciiStrnLenS (
1719 IN CONST CHAR8 *String,
1720 IN UINTN MaxSize
1721 )
1722{
1723 UINTN Length;
1724
1725 //
1726 // If String is a null pointer, then the AsciiStrnLenS function returns zero.
1727 //
1728 if (String == NULL) {
1729 return 0;
1730 }
1731
1732 //
1733 // Otherwise, the AsciiStrnLenS function returns the number of characters that precede the
1734 // terminating null character. If there is no null character in the first MaxSize characters of
1735 // String then AsciiStrnLenS returns MaxSize. At most the first MaxSize characters of String shall
1736 // be accessed by AsciiStrnLenS.
1737 //
1738 Length = 0;
1739 while (String[Length] != 0) {
1740 if (Length >= MaxSize - 1) {
1741 return MaxSize;
1742 }
1743 Length++;
1744 }
1745 return Length;
1746}
1747
1748/**
1749 Returns the size of a Null-terminated Ascii string in bytes, including the

Callers 9

AsciiStrnSizeSFunction · 0.85
AsciiStrnCpySFunction · 0.85
AsciiStrCatSFunction · 0.85
AsciiStrnCatSFunction · 0.85
AsciiStrnToUnicodeStrSFunction · 0.85
BasePrintLibSPrintMarkerFunction · 0.85
AsciiValueToStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected