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)
|
||||
{
|
||||
while (registered_terrains) {
|
||||
int n;
|
||||
terrain_type * t = registered_terrains;
|
||||
registered_terrains = t->next;
|
||||
free(t->_name);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ extern "C" {
|
|||
|
||||
typedef struct terrain_production {
|
||||
const struct resource_type *type;
|
||||
const char *startlevel;
|
||||
const char *base;
|
||||
const char *divisor;
|
||||
char *startlevel;
|
||||
char *base;
|
||||
char *divisor;
|
||||
float chance;
|
||||
} terrain_production;
|
||||
|
||||
|
|
Loading…
Reference in New Issue