From 50edaa578b614eb74c57a38faa2d05ab628ff81b Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 1 Jun 2005 17:47:56 +0000 Subject: Miscellaneous fixes from James Harvey's PalmOS porting work: - fixed numerous memory leaks (not Palm-specific) - corrected a couple of 32-bit-int assumptions (vital for Palm but generally a good thing anyway) - lifted a few function pointer types into explicit typedefs (neutral for me but convenient for the source-munging Perl scripts he uses to deal with Palm code segment rules) - lifted a few function-level static arrays into global static arrays (neutral for me but apparently works round a Palm tools bug) - a couple more presets in Rectangles (so that Palm, or any other slow platform which can't handle the larger sizes easily, can still have some variety available) - in Solo, arranged a means of sharing scratch space between calls to nsolve to prevent a lot of redundant malloc/frees (gives a 10% speed increase even on existing platforms) [originally from svn r5897] --- cube.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cube.c') diff --git a/cube.c b/cube.c index cb6a1f9..0ff952f 100644 --- a/cube.c +++ b/cube.c @@ -300,10 +300,9 @@ static char *encode_params(game_params *params, int full) return dupstr(data); } +typedef void (*egc_callback)(void *, struct grid_square *); -static void enum_grid_squares(game_params *params, - void (*callback)(void *, struct grid_square *), - void *ctx) +static void enum_grid_squares(game_params *params, egc_callback callback, void *ctx) { const struct solid *solid = solids[params->solid]; @@ -979,6 +978,8 @@ static game_state *dup_game(game_state *state) static void free_game(game_state *state) { + sfree(state->squares); + sfree(state->facecolours); sfree(state); } @@ -1233,6 +1234,7 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds, success = align_poly(poly, &from->squares[ret->current], all_pkey); if (!success) { + sfree(poly); angle = -angle; poly = transform_poly(from->solid, from->squares[from->current].flip, @@ -1572,8 +1574,8 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, } sfree(poly); - draw_update(fe, 0, 0, (int)((bb.r-bb.l+2.0F) * GRID_SCALE), - (int)((bb.d-bb.u+2.0F) * GRID_SCALE)); + game_size(&state->params, &i, &j); + draw_update(fe, 0, 0, i, j); /* * Update the status bar. -- cgit v1.1