diff options
author | Michael McConville <mmcconville ~a~ mykolab ~d~ com> | 2015-09-16 23:42:36 -0400 |
---|---|---|
committer | Michael McConville <mmcconville ~a~ mykolab ~d~ com> | 2015-09-16 23:42:36 -0400 |
commit | 445222e48c380bbb5d209a82f9614187bc751b41 (patch) | |
tree | 6d236f6744ed7a61a754385519395a2932d66d3b /StringUtils.c | |
parent | 1d805b36b429f5157dd0de6f0b498941aa097941 (diff) |
Clean up some needless malloc casts, convert some mallocs to callocs, and fix some style
Diffstat (limited to 'StringUtils.c')
-rw-r--r-- | StringUtils.c | 6 |
1 files changed, 3 insertions, 3 deletions
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++; |