diff options
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c index 1132a94..ee41735 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,5 @@ #include <pcre2.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -83,6 +84,17 @@ int regex_match(const char *subject, str_array_t patterns, return 0; } +int repchr(char *str, char t, char r) { + int c = 0; + for (size_t i = 0; str[i] != '\0'; i++) { + if (str[i] == t) { + str[i] = r; + c++; + } + } + return c; +} + generic_array_t create_array(size_t elem_size, size_t n) { generic_array_t array; array.data = n ? malloc(elem_size * n) : NULL; |