Add SDK/CRT string routines and headers
This commit is contained in:
45
SDK/CRT/STRING/str.c
Normal file
45
SDK/CRT/STRING/str.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*++
|
||||
|
||||
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);
|
||||
}
|
Reference in New Issue
Block a user