diff --git a/libc/include/string.h b/libc/include/string.h index dc58e4d8..9f2055e3 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -26,6 +26,9 @@ extern "C" /* Return the length of a null-terminated string. */ size_t strlen(const char* str); + /* Return the length of a fixed-size null-terminated string. */ + size_t strnlen(const char* str, size_t max); + /* Compare two null-terminated strings. */ int strcmp(const char* a, const char* b); @@ -56,6 +59,12 @@ extern "C" /* Separate a string into several tokens. */ char* strtok(char* str, const char* delim); + /* Return a heap-allocated copy of a fixed-size string. */ + char* strndup(const char* str, size_t max); + + /* Copy up to max bytes of src into dest, adding a null terminator at the end. */ + size_t strlcpy(char* dest, const char* src, size_t max); + #ifdef __cplusplus } #endif