diff --git a/include/r3_str.h b/include/r3_str.h index 4aeced1..f5f8935 100644 --- a/include/r3_str.h +++ b/include/r3_str.h @@ -24,8 +24,6 @@ char * inside_slug(char * needle, int needle_len, char *offset); char * ltrim_slash(char* str); -char** str_split(char* a_str, const char a_delim); - void str_repeat(char *s, char *c, int len); void print_indent(int level); diff --git a/src/str.c b/src/str.c index 73b2c80..92d460b 100644 --- a/src/str.c +++ b/src/str.c @@ -174,54 +174,6 @@ char * ltrim_slash(char* str) return strdup(p); } -char** str_split(char* a_str, const char a_delim) -{ - char** result = 0; - size_t count = 0; - char* tmp = a_str; - char* last_comma = 0; - char delim[2]; - delim[0] = a_delim; - delim[1] = 0; - - /* Count how many elements will be extracted. */ - while (*tmp) - { - if (a_delim == *tmp) - { - count++; - last_comma = tmp; - } - tmp++; - } - - /* Add space for trailing token. */ - count += last_comma < (a_str + strlen(a_str) - 1); - - /* Add space for terminating null string so caller - knows where the list of returned strings ends. */ - count++; - - result = malloc(sizeof(char*) * count); - - if (result) - { - size_t idx = 0; - char* token = strtok(a_str, delim); - - while (token) - { - assert(idx < count); - *(result + idx++) = strdup(token); - token = strtok(0, delim); - } - assert(idx == count - 1); - *(result + idx) = 0; - } - - return result; -} - void str_repeat(char *s, char *c, int len) { while(len--) { s[len - 1] = *c; diff --git a/tests/bench_str.csv b/tests/bench_str.csv index c76d5e1..06803c9 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -386,3 +386,4 @@ 1400593219,13704926.07 1400599508,13991454.07 1400599553,13826120.84 +1400599756,12099437.82