Returns the length of a Null-terminated Unicode string. This function is similar as strlen_s defined in C11. If String is not aligned on a 16-bit boundary, then ASSERT(). @param String A pointer to a Null-terminated Unicode string. @param MaxSize The maximum number of Destination Unicode char, including terminating null char. Slice: NOT including @r
| 118 | StrnLenS(string, 9) = 6; |
| 119 | **/ |
| 120 | UINTN |
| 121 | EFIAPI |
| 122 | StrnLenS ( |
| 123 | IN CONST CHAR16 *String, |
| 124 | IN UINTN MaxSize |
| 125 | ) |
| 126 | { |
| 127 | UINTN Length; |
| 128 | |
| 129 | ASSERT (((UINTN) String & BIT0) == 0); |
| 130 | |
| 131 | // |
| 132 | // If String is a null pointer, then the StrnLenS function returns zero. |
| 133 | // |
| 134 | if (String == NULL) { |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | // |
| 139 | // Otherwise, the StrnLenS function returns the number of characters that precede the |
| 140 | // terminating null character. If there is no null character in the first MaxSize characters of |
| 141 | // String then StrnLenS returns MaxSize. At most the first MaxSize characters of String shall |
| 142 | // be accessed by StrnLenS. |
| 143 | // |
| 144 | Length = 0; |
| 145 | while (String[Length] != 0) { |
| 146 | if (Length >= MaxSize - 1) { |
| 147 | return MaxSize; |
| 148 | } |
| 149 | Length++; |
| 150 | } |
| 151 | return Length; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | Returns the size of a Null-terminated Unicode string in bytes, including the |
no outgoing calls
no test coverage detected