free(NULL) is a valid no-op, so let's make String_freeArray(NULL) valid too.

This commit is contained in:
Hisham 2016-08-24 18:12:35 -03:00
parent bd5d37f297
commit cceab15b9d
1 changed files with 3 additions and 0 deletions

View File

@ -93,6 +93,9 @@ char** String_split(const char* s, char sep, int* n) {
}
void String_freeArray(char** s) {
if (!s) {
return;
}
for (int i = 0; s[i] != NULL; i++) {
free(s[i]);
}