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

Function StrnLenS

MdePkg/Library/BaseLib/SafeString.c:120–152  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

118 StrnLenS(string, 9) = 6;
119**/
120UINTN
121EFIAPI
122StrnLenS (
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

Callers 15

StrnSizeSFunction · 0.70
StrnCpySFunction · 0.70
StrCatSFunction · 0.70
StrnCatSFunction · 0.70
UnicodeStrnToAsciiStrSFunction · 0.70
BasePrintLibSPrintMarkerFunction · 0.50
DevPathFromTextUriFunction · 0.50
ConvertProcessorToStringFunction · 0.50
SetQuestionValueFunction · 0.50
EvaluateExpressionFunction · 0.50
ExtractConfigFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected