tiles: Remove TiJoinFree() now that TiJoin[XY]1() exists and all use-cases utilize
This commit is contained in:
parent
fd50bc1f4d
commit
4023ed9da0
63
tiles/tile.c
63
tiles/tile.c
|
|
@ -493,63 +493,6 @@ TiSplitY_Bottom(
|
||||||
return (newtile);
|
return (newtile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Obnoxious global variable introduced to fix a use-after-free issue
|
|
||||||
* in DBMergeNMTiles0(); should get cleaned up when the one-delayed-free
|
|
||||||
* method gets purged from the code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static Tile *tile_join_TiFree = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* --------------------------------------------------------------------
|
|
||||||
* TiJoinFreeFinal --
|
|
||||||
*
|
|
||||||
* Manages use-after free style bugs relating to the use of TiJoin{X,Y}
|
|
||||||
*
|
|
||||||
* Results: None
|
|
||||||
*
|
|
||||||
* Side effects: Calls TiFree() and may modify the global variable
|
|
||||||
* tile_join_TiFree.
|
|
||||||
*
|
|
||||||
* --------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
TiJoinFreeFinal(void)
|
|
||||||
{
|
|
||||||
Tile *tile = tile_join_TiFree;
|
|
||||||
if (tile)
|
|
||||||
{
|
|
||||||
tile_join_TiFree = NULL;
|
|
||||||
TiFree(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* --------------------------------------------------------------------
|
|
||||||
* TiJoinFree --
|
|
||||||
*
|
|
||||||
* Tile deallocation function to use with TiJoinX() and TiJoinY(),
|
|
||||||
* running TiJoinFreeFinal() and using the global variable
|
|
||||||
* tile_join_TiFree to avoid issues with the one-delayed-free
|
|
||||||
* method. It's a bit of a hack, but it solves the problem.
|
|
||||||
*
|
|
||||||
* Results: None
|
|
||||||
*
|
|
||||||
* Side effects: Sets global variable tile_join_TiFree to point to
|
|
||||||
* the freed tile so that it won't get accidentally used before
|
|
||||||
* it is reallocated.
|
|
||||||
*
|
|
||||||
* --------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
TiJoinFree(Tile* tile)
|
|
||||||
{
|
|
||||||
TiJoinFreeFinal();
|
|
||||||
tile_join_TiFree = tile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
|
|
@ -557,6 +500,8 @@ TiJoinFree(Tile* tile)
|
||||||
*
|
*
|
||||||
* Given two tiles sharing an entire common vertical edge, replace
|
* Given two tiles sharing an entire common vertical edge, replace
|
||||||
* them with a single tile occupying the union of their areas.
|
* them with a single tile occupying the union of their areas.
|
||||||
|
* Caller is expected to TiFree(tile2) upon return.
|
||||||
|
* See TiJoinX1() to managing delayed TiFree().
|
||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* None.
|
* None.
|
||||||
|
|
@ -632,7 +577,6 @@ TiJoinX(
|
||||||
|
|
||||||
if (PlaneGetHint(plane) == tile2)
|
if (PlaneGetHint(plane) == tile2)
|
||||||
PlaneSetHint(plane, tile1);
|
PlaneSetHint(plane, tile1);
|
||||||
TiJoinFree(tile2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -642,6 +586,8 @@ TiJoinX(
|
||||||
*
|
*
|
||||||
* Given two tiles sharing an entire common horizontal edge, replace
|
* Given two tiles sharing an entire common horizontal edge, replace
|
||||||
* them with a single tile occupying the union of their areas.
|
* them with a single tile occupying the union of their areas.
|
||||||
|
* Caller is expected to TiFree(tile2) upon return.
|
||||||
|
* See TiJoinY1() to managing delayed TiFree().
|
||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* None.
|
* None.
|
||||||
|
|
@ -717,7 +663,6 @@ TiJoinY(
|
||||||
|
|
||||||
if (PlaneGetHint(plane) == tile2)
|
if (PlaneGetHint(plane) == tile2)
|
||||||
PlaneSetHint(plane, tile1);
|
PlaneSetHint(plane, tile1);
|
||||||
TiJoinFree(tile2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue