frees the buffer after a quickload (nw)

This commit is contained in:
smf- 2013-04-27 12:36:16 +00:00
parent 2582fa1897
commit f0e4777b1e

View File

@ -172,6 +172,7 @@ QUICKLOAD_LOAD_MEMBER( cd2650_state, cd2650 )
int quick_length;
UINT8 *quick_data;
int read_;
int result = IMAGE_INIT_FAIL;
quick_length = image.length();
quick_data = (UINT8*)malloc(quick_length);
@ -179,47 +180,41 @@ QUICKLOAD_LOAD_MEMBER( cd2650_state, cd2650 )
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file");
image.message(" Cannot open file");
return IMAGE_INIT_FAIL;
}
else
{
read_ = image.fread( quick_data, quick_length);
if (read_ != quick_length)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file");
image.message(" Cannot read the file");
return IMAGE_INIT_FAIL;
}
if (quick_data[0] != 0x40)
else if (quick_data[0] != 0x40)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
image.message(" Invalid header");
return IMAGE_INIT_FAIL;
}
else
{
exec_addr = quick_data[1] * 256 + quick_data[2];
if (exec_addr >= quick_length)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file");
image.message(" Exec address beyond end of file");
return IMAGE_INIT_FAIL;
}
if (quick_length < 0x0444)
else if (quick_length < 0x0444)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short");
image.message(" File too short");
return IMAGE_INIT_FAIL;
}
if (quick_length > 0x8000)
else if (quick_length > 0x8000)
{
image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long");
image.message(" File too long");
return IMAGE_INIT_FAIL;
}
else
{
read_ = 0x1000;
if (quick_length < 0x1000)
read_ = quick_length;
@ -244,7 +239,15 @@ QUICKLOAD_LOAD_MEMBER( cd2650_state, cd2650 )
// Start the quickload
m_maincpu->set_pc(exec_addr);
return IMAGE_INIT_PASS;
result = IMAGE_INIT_PASS;
}
}
free( quick_data );
}
return result;
}
static MACHINE_CONFIG_START( cd2650, cd2650_state )