[Fix] Fix to address realloc not freeing with 0 size on freebsd. Still
needed in other places too.
This commit is contained in:
parent
4455499beb
commit
30a0f3c7b7
@ -1126,8 +1126,12 @@ int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
|
|||||||
memmove(&pilot->outfits[i], &pilot->outfits[i+1],
|
memmove(&pilot->outfits[i], &pilot->outfits[i+1],
|
||||||
sizeof(PilotOutfit)*(pilot->noutfits-i-1));
|
sizeof(PilotOutfit)*(pilot->noutfits-i-1));
|
||||||
pilot->noutfits--;
|
pilot->noutfits--;
|
||||||
|
if(pilot->noutfits == 0) {
|
||||||
|
free(pilot->outfits);
|
||||||
|
pilot->outfits = NULL;
|
||||||
|
} else
|
||||||
pilot->outfits = realloc(pilot->outfits,
|
pilot->outfits = realloc(pilot->outfits,
|
||||||
sizeof(PilotOutfit)*(pilot->noutfits));
|
sizeof(PilotOutfit) * (pilot->noutfits));
|
||||||
|
|
||||||
/* Set secondary and afterburner. */
|
/* Set secondary and afterburner. */
|
||||||
pilot_setSecondary(pilot, osec);
|
pilot_setSecondary(pilot, osec);
|
||||||
|
Loading…
Reference in New Issue
Block a user