MCPcopy Create free account
hub / github.com/HelenOS/helenos / wstr_nlength

Function wstr_nlength

kernel/generic/src/lib/str.c:416–428  ·  view source on GitHub ↗

Get number of characters in a string with size limit. * * @param str NULL-terminated string. * @param size Maximum number of bytes to consider. * * @return Number of characters in string. * */

Source from the content-addressed store, hash-verified

414 *
415 */
416size_t wstr_nlength(const char32_t *str, size_t size)
417{
418 size_t len = 0;
419 size_t limit = ALIGN_DOWN(size, sizeof(char32_t));
420 size_t offset = 0;
421
422 while ((offset < limit) && (*str++ != 0)) {
423 len++;
424 offset += sizeof(char32_t);
425 }
426
427 return len;
428}
429
430/** Check whether character is plain ASCII.
431 *

Callers 1

wstr_lsizeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected