forked from github/server
memory leak: properly free terrain_production objects
This commit is contained in:
parent
59e2c12605
commit
c707ff39b6
|
@ -59,10 +59,18 @@ static terrain_type *registered_terrains;
|
||||||
void free_terrains(void)
|
void free_terrains(void)
|
||||||
{
|
{
|
||||||
while (registered_terrains) {
|
while (registered_terrains) {
|
||||||
|
int n;
|
||||||
terrain_type * t = registered_terrains;
|
terrain_type * t = registered_terrains;
|
||||||
registered_terrains = t->next;
|
registered_terrains = t->next;
|
||||||
free(t->_name);
|
free(t->_name);
|
||||||
free(t->production);
|
if (t->production) {
|
||||||
|
for (n = 0; t->production[n].type; ++n) {
|
||||||
|
free(t->production[n].base);
|
||||||
|
free(t->production[n].divisor);
|
||||||
|
free(t->production[n].startlevel);
|
||||||
|
}
|
||||||
|
free(t->production);
|
||||||
|
}
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,9 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct terrain_production {
|
typedef struct terrain_production {
|
||||||
const struct resource_type *type;
|
const struct resource_type *type;
|
||||||
const char *startlevel;
|
char *startlevel;
|
||||||
const char *base;
|
char *base;
|
||||||
const char *divisor;
|
char *divisor;
|
||||||
float chance;
|
float chance;
|
||||||
} terrain_production;
|
} terrain_production;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue