Fix: 01530: Various Drivers: bitmap memory leaks

This commit is contained in:
Zsolt Vasvari 2008-03-15 14:14:03 +00:00
parent 16e18f24af
commit c66bb0adc5

View File

@ -136,7 +136,12 @@ static void animate(const device_config *device, int vblank_state);
static void create_bitmap(int player) static void create_bitmap(int player)
{ {
/* if we don't have a bitmap for this player yet */
if (global.bitmap[player] == NULL)
{
int x, y;
char filename[20]; char filename[20];
rgb_t color = crosshair_colors[player];
/* first try to load a bitmap for the crosshair */ /* first try to load a bitmap for the crosshair */
sprintf(filename, "cross%d.png", player); sprintf(filename, "cross%d.png", player);
@ -145,9 +150,6 @@ static void create_bitmap(int player)
/* if that didn't work, use the built-in one */ /* if that didn't work, use the built-in one */
if (global.bitmap[player] == NULL) if (global.bitmap[player] == NULL)
{ {
rgb_t color = crosshair_colors[player];
int x, y;
/* allocate a blank bitmap to start with */ /* allocate a blank bitmap to start with */
global.bitmap[player] = bitmap_alloc(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE, BITMAP_FORMAT_ARGB32); global.bitmap[player] = bitmap_alloc(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE, BITMAP_FORMAT_ARGB32);
fillbitmap(global.bitmap[player], MAKE_ARGB(0x00,0xff,0xff,0xff), NULL); fillbitmap(global.bitmap[player], MAKE_ARGB(0x00,0xff,0xff,0xff), NULL);
@ -170,6 +172,7 @@ static void create_bitmap(int player)
global.texture[player] = render_texture_alloc(render_texture_hq_scale, NULL); global.texture[player] = render_texture_alloc(render_texture_hq_scale, NULL);
render_texture_set_bitmap(global.texture[player], global.bitmap[player], NULL, 0, TEXFORMAT_ARGB32); render_texture_set_bitmap(global.texture[player], global.bitmap[player], NULL, 0, TEXFORMAT_ARGB32);
} }
}
/*------------------------------------------------- /*-------------------------------------------------
@ -179,15 +182,13 @@ static void create_bitmap(int player)
void crosshair_init(running_machine *machine) void crosshair_init(running_machine *machine)
{ {
int player;
input_port_entry *ipt; input_port_entry *ipt;
/* request a callback upon exiting */ /* request a callback upon exiting */
add_exit_callback(machine, crosshair_exit); add_exit_callback(machine, crosshair_exit);
/* nothing is used by default */ /* clear all the globals */
for (player = 0; player < MAX_PLAYERS; player++) memset(&global, 0, sizeof(global));
global.used[player] = FALSE;
/* determine who needs crosshairs */ /* determine who needs crosshairs */
for (ipt = machine->input_ports; ipt->type != IPT_END; ipt++) for (ipt = machine->input_ports; ipt->type != IPT_END; ipt++)
@ -195,6 +196,8 @@ void crosshair_init(running_machine *machine)
{ {
int player = ipt->player; int player = ipt->player;
assert(player < MAX_PLAYERS);
/* mark as used and visible */ /* mark as used and visible */
global.used[player] = TRUE; global.used[player] = TRUE;
global.visible[player] = TRUE; global.visible[player] = TRUE;