mirror of
https://github.com/holub/mame
synced 2025-07-05 18:08:04 +03:00
formats/apridisk.cpp: Don't use megabytes of stack space.
This commit is contained in:
parent
d5e8303a90
commit
0590cd598a
@ -459,7 +459,7 @@ image_init_result floppy_image_device::call_load()
|
||||
io.filler = 0xff;
|
||||
int best = 0;
|
||||
floppy_image_format_t *best_format = nullptr;
|
||||
for(floppy_image_format_t *format = fif_list; format; format = format->next) {
|
||||
for (floppy_image_format_t *format = fif_list; format; format = format->next) {
|
||||
int score = format->identify(&io, form_factor);
|
||||
if(score > best) {
|
||||
best = score;
|
||||
@ -467,15 +467,13 @@ image_init_result floppy_image_device::call_load()
|
||||
}
|
||||
}
|
||||
|
||||
if(!best_format)
|
||||
{
|
||||
if (!best_format) {
|
||||
seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to identify the image format");
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
image = std::make_unique<floppy_image>(tracks, sides, form_factor);
|
||||
if (!best_format->load(&io, form_factor, image.get()))
|
||||
{
|
||||
if (!best_format->load(&io, form_factor, image.get())) {
|
||||
seterror(IMAGE_ERROR_UNSUPPORTED, "Incompatible image format or corrupted data");
|
||||
image.reset();
|
||||
return image_init_result::FAIL;
|
||||
|
@ -48,8 +48,8 @@ int apridisk_format::identify(io_generic *io, uint32_t form_factor)
|
||||
bool apridisk_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
|
||||
{
|
||||
desc_pc_sector sectors[80][2][18];
|
||||
uint8_t sector_data[MAX_SECTORS * SECTOR_SIZE];
|
||||
uint8_t *data_ptr = sector_data;
|
||||
std::unique_ptr<uint8_t []> sector_data(new uint8_t [MAX_SECTORS * SECTOR_SIZE]);
|
||||
uint8_t *data_ptr = sector_data.get();
|
||||
int track_count = 0, head_count = 0, sector_count = 0;
|
||||
|
||||
uint64_t file_size = io_generic_size(io);
|
||||
|
Loading…
Reference in New Issue
Block a user