From 445222e48c380bbb5d209a82f9614187bc751b41 Mon Sep 17 00:00:00 2001 From: Michael McConville Date: Wed, 16 Sep 2015 23:42:36 -0400 Subject: Clean up some needless malloc casts, convert some mallocs to callocs, and fix some style --- StringUtils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'StringUtils.c') diff --git a/StringUtils.c b/StringUtils.c index 834b4311..54a61584 100644 --- a/StringUtils.c +++ b/StringUtils.c @@ -55,13 +55,13 @@ inline int String_eq(const char* s1, const char* s2) { char** String_split(const char* s, char sep, int* n) { *n = 0; const int rate = 10; - char** out = (char**) malloc(sizeof(char*) * rate); + char** out = calloc(rate, sizeof(char**)); int ctr = 0; int blocks = rate; char* where; while ((where = strchr(s, sep)) != NULL) { int size = where - s; - char* token = (char*) malloc(size + 1); + char* token = malloc(size + 1); strncpy(token, s, size); token[size] = '\0'; out[ctr] = token; @@ -80,7 +80,7 @@ char** String_split(const char* s, char sep, int* n) { } if (s[0] != '\0') { int size = strlen(s); - char* token = (char*) malloc(size + 1); + char* token = malloc(size + 1); strncpy(token, s, size + 1); out[ctr] = token; ctr++; -- cgit v1.2.3