memory leak: finally found that coast leak. bad test was overwriting coasts without free (setting custom coasts in a test is not easy).

This commit is contained in:
Enno Rehling 2016-03-11 11:52:36 +01:00
parent 637054bc22
commit d83bd3bec5
1 changed files with 2 additions and 0 deletions

View File

@ -47,6 +47,7 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha
if (v_shiptype) { if (v_shiptype) {
st_boat = st_get_or_create(v_shiptype); st_boat = st_get_or_create(v_shiptype);
u_set_ship(*victim, test_create_ship((*victim)->region, st_boat)); u_set_ship(*victim, test_create_ship((*victim)->region, st_boat));
free(st_boat->coasts);
st_boat->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *)); st_boat->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *));
st_boat->coasts[0] = vterrain; st_boat->coasts[0] = vterrain;
st_boat->coasts[1] = 0; st_boat->coasts[1] = 0;
@ -59,6 +60,7 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha
if (p_shiptype) { if (p_shiptype) {
st_boat = st_get_or_create(p_shiptype); st_boat = st_get_or_create(p_shiptype);
u_set_ship(*pirate, test_create_ship((*pirate)->region, st_boat)); u_set_ship(*pirate, test_create_ship((*pirate)->region, st_boat));
free(st_boat->coasts);
st_boat->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *)); st_boat->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *));
st_boat->coasts[0] = vterrain; st_boat->coasts[0] = vterrain;
st_boat->coasts[1] = 0; st_boat->coasts[1] = 0;