alcyone/SDK/CRT/STRING/str.c

46 lines
501 B
C

/*++
Copyright (c) 2024, Quinn Stephens.
Provided under the BSD 3-Clause license.
Module Name:
str.c
Abstract:
Provides string manipulation routines.
--*/
#include <string.h>
size_t
strlen (
const char *str
)
{
const char *ptr;
ptr = str;
while (*ptr++);
return ptr - str - sizeof(char);
}
size_t
strnlen (
const char *str,
size_t maxlen
)
{
size_t len;
len = 0;
while (len < maxlen && str[len++]);
return len - sizeof(char);
}