diff --git a/docs/string.md b/docs/string.md index 0e4bd39..b7444a9 100644 --- a/docs/string.md +++ b/docs/string.md @@ -13,7 +13,7 @@ and subsequently the size of `substrings`. If no substrings are found, `substrings` will not be allocated and left set to `NULL`, `num_substrings` will be `0`, and the function will return `0`. -Returns 0 if the function is successful, returns a non-zero value and prints to `stderr` if there is an error. +Returns 0 if the function is successful. Returns a non-zero value if there is an error. ```c int find_substrings(const char* haystack, const char* needle, size_t *num_substrings, size_t **substrings); @@ -34,7 +34,7 @@ free(subs); ### substr Extracts a substring at a specific index and length. This function returns a copy of the substring in a heap allocated -buffer that the user is responsible for freeing. Returns `NULL` and prints to `stderr` if there is an error. +buffer that the user is responsible for freeing. Returns `NULL` if there is an error. ```c const char* substr(const char* str, size_t idx, size_t len); diff --git a/mkdocs.yml b/mkdocs.yml index 9a013d5..7f3223a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -12,5 +12,6 @@ nav: - 'Math': 'math.md' - 'Set': 'set.md' - 'Stack': 'stack.md' + - 'String': 'string.md' - 'Utility': 'utility.md' - 'Vector': 'vector.md' diff --git a/src/string.c b/src/string.c index 22bf91f..f277c5c 100644 --- a/src/string.c +++ b/src/string.c @@ -1,12 +1,10 @@ #include #include -#include #include "lfstring.h" int find_substrings(const char* haystack, const char* needle, size_t *num_substrings, size_t **substrings) { if (*substrings != NULL) { - fprintf(stderr, "substrings was not NULL in find_substring\n"); return 1; } @@ -29,7 +27,6 @@ int find_substrings(const char* haystack, const char* needle, size_t *num_substr *substrings = malloc(sizeof(size_t) * *num_substrings); if (*substrings == NULL) { - fprintf(stderr, "Memory allocation failed in find_substrings\n"); return -1; } @@ -46,13 +43,11 @@ int find_substrings(const char* haystack, const char* needle, size_t *num_substr const char* substr(const char* str, size_t idx, size_t len) { size_t sz_str = strlen(str); if (sz_str < len || idx + len > sz_str) { - fprintf(stderr, "Improper size arguments in substr\n"); return NULL; } char *substr = malloc(sizeof(char) * len + 1); if (substr == NULL) { - fprintf(stderr, "Memory allocation error in substr\n"); return NULL; }