Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBtiles.c: DBFreePaintPlane() remove the TiFree() deferred assumption #380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions database/DBtiles.c
Original file line number Diff line number Diff line change
@@ -723,9 +723,7 @@ DBResetTilePlane(plane, cdata)
*
* This procedure uses a carfully constructed non-recursive area
* enumeration algorithm. Care is taken to not access a tile that has
* been deallocated. The only exception is for a tile that has just been
* passed to free(), but no more calls to free() or malloc() have been made.
* Magic's malloc allows this.
* been deallocated.
*
* --------------------------------------------------------------------
*/
@@ -762,19 +760,21 @@ DBFreePaintPlane(plane)
/* Each iteration returns one tile further to the right */
while (RIGHT(tp) < rect->r_xtop)
{
TiFree(tp);
tpnew = RT(tp);
tp = TR(tp);
Tile *tr_tmp = TR(tp);
TiFree(tp);
tp = tr_tmp; //TR(tp);
if (CLIP_TOP(tpnew) <= CLIP_TOP(tp) && BOTTOM(tpnew) < rect->r_ytop)
{
tp = tpnew;
goto enumerate;
}
}

TiFree(tp);
Tile *tp_free = tp;
/* At right edge -- walk up to next tile along the right edge */
tp = RT(tp);
TiFree(tp_free);
if (BOTTOM(tp) < rect->r_ytop) {
while(LEFT(tp) >= rect->r_xtop) tp = BL(tp);
}
6 changes: 6 additions & 0 deletions database/database.h.in
Original file line number Diff line number Diff line change
@@ -25,6 +25,9 @@
#ifndef _DATABASE_H
#define _DATABASE_H

#include <assert.h>
//#include "utils/magic_assert.h" // FIXME does not exist yet

#ifndef _TILES_H
#include "tiles/tile.h"
#endif /* _TILES_H */
@@ -89,12 +92,15 @@ typedef int TileType;
* Note that the value of 5 for TT_WORDSHIFT effectively requires that
* bits-per-word equal 32 or havoc is likely to result.
*/
_Static_assert(sizeof (unsigned int) == 4, "TileTypeBitMask sizeof(unsigned int)");

#define TT_BPW (8 * sizeof (unsigned int))
#define TT_WORDMASK (TT_BPW - 1)
#define TT_WORDSHIFT 5 /* LOG2(TT_BPW) */
#define TT_MASKWORDS ((TT_MAXTYPES + TT_BPW - 1) / TT_BPW)

_Static_assert((1<<TT_WORDSHIFT) == TT_BPW, "TileTypeBitMask computation"); /* crosscheck */

typedef struct
{
unsigned int tt_words[TT_MASKWORDS];