forked from github/server
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:
parent
637054bc22
commit
d83bd3bec5
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue