MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / locoStrlen

Function locoStrlen

src/OpenLoco/src/Localisation/Formatting.cpp:208–232  ·  view source on GitHub ↗

Loco string argument safe strlen

Source from the content-addressed store, hash-verified

206
207 // Loco string argument safe strlen
208 size_t locoStrlen(const char* buffer)
209 {
210 if (buffer == nullptr)
211 {
212 return 0;
213 }
214 auto* ptr = buffer;
215 while (*ptr != '\0')
216 {
217 const auto ch = *ptr++;
218 if (ch >= ControlCodes::oneArgBegin && ch < ControlCodes::oneArgEnd)
219 {
220 ptr++;
221 }
222 else if (ch >= ControlCodes::twoArgBegin && ch < ControlCodes::twoArgEnd)
223 {
224 ptr += 2;
225 }
226 else if (ch >= ControlCodes::fourArgBegin && ch < ControlCodes::fourArgEnd)
227 {
228 ptr += 4;
229 }
230 }
231 return ptr - buffer;
232 }
233
234 // Loco string argument safe strlen_s
235 size_t locoStrlenS(const char* buffer, std::size_t size)

Callers 7

postFunction · 0.85
getIndustryArgumentsFunction · 0.85
scrollMouseOverFunction · 0.85
wrapStringFunction · 0.85
wrapStringTickerFunction · 0.85
drawDescriptionMethod · 0.85
locoStrcpyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected