From: Holger Schemel Date: Mon, 19 Feb 2024 22:50:01 +0000 (+0100) Subject: added function to free string array X-Git-Tag: 4.4.0.0-test-1~338 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c712eddd108764ffbf523830ba2a26869e1453c8;p=rocksndiamonds.git added function to free string array --- diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 0f4cab03..2ef55766 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1295,6 +1295,19 @@ char **getSplitStringArray(const char *s, const char *separators, int max_tokens return tokens; } +void freeStringArray(char **s_array) +{ + int i; + + if (s_array == NULL) + return; + + for (i = 0; s_array[i] != NULL; i++) + checked_free(s_array[i]); + + checked_free(s_array); +} + boolean strEqual(const char *s1, const char *s2) { return (s1 == NULL && s2 == NULL ? TRUE : diff --git a/src/libgame/misc.h b/src/libgame/misc.h index cee6c113..00228fcf 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -182,6 +182,7 @@ char *getStringCopyNStatic(const char *, int); char *getStringToLower(const char *); void setString(char **, const char *); char **getSplitStringArray(const char *s, const char *, int); +void freeStringArray(char **); boolean strEqual(const char *, const char *); boolean strEqualN(const char *, const char *, int); boolean strEqualCase(const char *, const char *);