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
| 1714 | |
| 1715 | **/ |
| 1716 | UINTN |
| 1717 | EFIAPI |
| 1718 | AsciiStrnLenS ( |
| 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 |
no outgoing calls
no test coverage detected