free race prefixes when the game is done (small memory leak).

This commit is contained in:
Enno Rehling 2015-09-12 12:29:42 +02:00
parent f1476c2167
commit 44d982d210
3 changed files with 15 additions and 1 deletions

View File

@ -74,6 +74,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/xml.h> #include <util/xml.h>
#include "donations.h" #include "donations.h"
#include "prefix.h"
#ifdef USE_LIBXML2 #ifdef USE_LIBXML2
/* libxml includes */ /* libxml includes */
@ -1767,6 +1768,7 @@ void free_gamedata(void)
free_units(); free_units();
free_regions(); free_regions();
free_borders(); free_borders();
free_prefixes();
for (i = 0; i != MAXLOCALES; ++i) { for (i = 0; i != MAXLOCALES; ++i) {
if (defaults[i]) { if (defaults[i]) {

View File

@ -19,3 +19,14 @@ void add_raceprefix(const char *prefix)
race_prefixes[next++] = _strdup(prefix); race_prefixes[next++] = _strdup(prefix);
race_prefixes[next] = NULL; race_prefixes[next] = NULL;
} }
void free_prefixes(void) {
int i;
if (race_prefixes) {
for (i = 0; race_prefixes[i]; ++i) {
free(race_prefixes[i]);
}
free(race_prefixes);
race_prefixes = 0;
}
}

View File

@ -8,7 +8,8 @@ extern "C" {
#endif #endif
void add_raceprefix(const char *); void add_raceprefix(const char *);
char **race_prefixes; char **race_prefixes; // zero-terminated array of valid prefixes
void free_prefixes(void);
#ifdef __cplusplus #ifdef __cplusplus
} }