diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-08-29 20:45:29 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-08-29 20:45:29 +0000 |
commit | 27b470e10d0ed2095e9e132193a6ae1ecff918bf (patch) | |
tree | a59fbabb080146532c6496bc36238dca271f342e /String.c | |
parent | 5dfb46e14f1f31bb4354be91590c90a91a6b3a34 (diff) |
Don't simply trust that string splits were successful...
Diffstat (limited to 'String.c')
-rw-r--r-- | String.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -55,7 +55,8 @@ inline int String_eq(const char* s1, const char* s2) { return (strcmp(s1, s2) == 0); } -char** String_split(const char* s, char sep) { +char** String_split(const char* s, char sep, int* n) { + *n = 0; const int rate = 10; char** out = (char**) malloc(sizeof(char*) * rate); int ctr = 0; @@ -83,6 +84,7 @@ char** String_split(const char* s, char sep) { } out = realloc(out, sizeof(char*) * (ctr + 1)); out[ctr] = NULL; + *n = ctr; return out; } |