From: Holger Schemel Date: Mon, 19 Feb 2024 22:54:04 +0000 (+0100) Subject: added function to count strings in array X-Git-Tag: 4.4.0.0-test-1~336 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a52f531ad87a63674575f1de443bb7e31b737e7d;p=rocksndiamonds.git added function to count strings in array --- diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 2ef55766..2c3e4493 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; } +int getStringArrayLength(char **s_array) +{ + int num_strings = 0; + + if (s_array == NULL) + return 0; + + while (s_array[num_strings] != NULL) + num_strings++; + + return num_strings; +} + void freeStringArray(char **s_array) { int i; diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 00228fcf..50f0ddb2 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); +int getStringArrayLength(char **); void freeStringArray(char **); boolean strEqual(const char *, const char *); boolean strEqualN(const char *, const char *, int);