mirror of
https://github.com/holub/mame
synced 2025-06-30 07:58:56 +03:00
converted some malloc()/free() usage to dynamic_array/dynamic_buffer (nw)
This commit is contained in:
parent
4f1472b1a0
commit
eaf446ebc4
@ -855,9 +855,9 @@ casserr_t cassette_legacy_construct(cassette_image *cassette,
|
|||||||
casserr_t err;
|
casserr_t err;
|
||||||
int length;
|
int length;
|
||||||
int sample_count;
|
int sample_count;
|
||||||
void *bytes = NULL;
|
dynamic_buffer bytes;
|
||||||
void *chunk = NULL;
|
dynamic_buffer chunk;
|
||||||
INT16 *samples = NULL;
|
dynamic_array<INT16> samples;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
UINT64 offset = 0;
|
UINT64 offset = 0;
|
||||||
UINT64 size;
|
UINT64 size;
|
||||||
@ -880,12 +880,7 @@ casserr_t cassette_legacy_construct(cassette_image *cassette,
|
|||||||
args.sample_frequency = 11025;
|
args.sample_frequency = 11025;
|
||||||
|
|
||||||
/* allocate a buffer for the binary data */
|
/* allocate a buffer for the binary data */
|
||||||
chunk = malloc(args.chunk_size);
|
chunk.resize(args.chunk_size);
|
||||||
if (!chunk)
|
|
||||||
{
|
|
||||||
err = CASSETTE_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* determine number of samples */
|
/* determine number of samples */
|
||||||
if (args.chunk_sample_calc)
|
if (args.chunk_sample_calc)
|
||||||
@ -896,14 +891,9 @@ casserr_t cassette_legacy_construct(cassette_image *cassette,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = malloc(size);
|
bytes.resize(size);
|
||||||
if (!bytes)
|
|
||||||
{
|
|
||||||
err = CASSETTE_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
cassette_image_read(cassette, bytes, 0, size);
|
cassette_image_read(cassette, bytes, 0, size);
|
||||||
sample_count = args.chunk_sample_calc((const UINT8*)bytes, (int) size);
|
sample_count = args.chunk_sample_calc(bytes, (int)size);
|
||||||
|
|
||||||
if (args.header_samples < 0)
|
if (args.header_samples < 0)
|
||||||
args.header_samples = sample_count;
|
args.header_samples = sample_count;
|
||||||
@ -916,12 +906,7 @@ casserr_t cassette_legacy_construct(cassette_image *cassette,
|
|||||||
sample_count += args.header_samples + args.trailer_samples;
|
sample_count += args.header_samples + args.trailer_samples;
|
||||||
|
|
||||||
/* allocate a buffer for the completed samples */
|
/* allocate a buffer for the completed samples */
|
||||||
samples = (INT16*)malloc(sample_count * sizeof(*samples));
|
samples.resize(sample_count);
|
||||||
if (!samples)
|
|
||||||
{
|
|
||||||
err = CASSETTE_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if there has to be a header */
|
/* if there has to be a header */
|
||||||
if (args.header_samples > 0)
|
if (args.header_samples > 0)
|
||||||
@ -941,7 +926,7 @@ casserr_t cassette_legacy_construct(cassette_image *cassette,
|
|||||||
cassette_image_read(cassette, chunk, offset, args.chunk_size);
|
cassette_image_read(cassette, chunk, offset, args.chunk_size);
|
||||||
offset += args.chunk_size;
|
offset += args.chunk_size;
|
||||||
|
|
||||||
length = args.fill_wave(samples + pos, sample_count - pos, (UINT8*)chunk);
|
length = args.fill_wave(samples + pos, sample_count - pos, chunk);
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
{
|
{
|
||||||
err = CASSETTE_ERROR_INVALIDIMAGE;
|
err = CASSETTE_ERROR_INVALIDIMAGE;
|
||||||
@ -978,12 +963,6 @@ casserr_t cassette_legacy_construct(cassette_image *cassette,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (samples)
|
|
||||||
free(samples);
|
|
||||||
if (chunk)
|
|
||||||
free(chunk);
|
|
||||||
if (bytes)
|
|
||||||
free(bytes);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "formats/coco_dsk.h"
|
#include "formats/coco_dsk.h"
|
||||||
#include "formats/basicdsk.h"
|
#include "formats/basicdsk.h"
|
||||||
#include "imageutl.h"
|
#include "imageutl.h"
|
||||||
|
#include "coretmpl.h"
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
* JVC (Jeff Vavasour CoCo) format
|
* JVC (Jeff Vavasour CoCo) format
|
||||||
@ -719,7 +720,7 @@ static floperr_t coco_dmk_format_track(floppy_image_legacy *floppy, int head, in
|
|||||||
UINT8 *track_data;
|
UINT8 *track_data;
|
||||||
void *track_data_v;
|
void *track_data_v;
|
||||||
UINT32 max_track_size;
|
UINT32 max_track_size;
|
||||||
int *sector_map = NULL;
|
dynamic_array<int> sector_map;
|
||||||
|
|
||||||
sectors = option_resolution_lookup_int(params, PARAM_SECTORS);
|
sectors = option_resolution_lookup_int(params, PARAM_SECTORS);
|
||||||
sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH);
|
sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH);
|
||||||
@ -746,13 +747,8 @@ static floperr_t coco_dmk_format_track(floppy_image_legacy *floppy, int head, in
|
|||||||
track_data = (UINT8 *) track_data_v;
|
track_data = (UINT8 *) track_data_v;
|
||||||
|
|
||||||
/* set up sector map */
|
/* set up sector map */
|
||||||
sector_map = (int*)malloc(sectors * sizeof(*sector_map));
|
sector_map.resize(sectors);
|
||||||
if (!sector_map)
|
sector_map.clear(0xFF);
|
||||||
{
|
|
||||||
err = FLOPPY_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
memset(sector_map, 0xFF, sectors * sizeof(*sector_map));
|
|
||||||
|
|
||||||
physical_sector = 0;
|
physical_sector = 0;
|
||||||
for (logical_sector = 0; logical_sector < sectors; logical_sector++)
|
for (logical_sector = 0; logical_sector < sectors; logical_sector++)
|
||||||
@ -837,8 +833,6 @@ static floperr_t coco_dmk_format_track(floppy_image_legacy *floppy, int head, in
|
|||||||
memset(&track_data[track_position], 0x4e, max_track_size - track_position);
|
memset(&track_data[track_position], 0x4e, max_track_size - track_position);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (sector_map)
|
|
||||||
free(sector_map);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ static int csw_cas_to_wav_size( const UINT8 *casdata, int caslen )
|
|||||||
UINT8 CompressionType;
|
UINT8 CompressionType;
|
||||||
UINT8 Flags;
|
UINT8 Flags;
|
||||||
UINT8 HeaderExtensionLength;
|
UINT8 HeaderExtensionLength;
|
||||||
UINT8 *gz_ptr = NULL;
|
dynamic_buffer gz_ptr;
|
||||||
|
|
||||||
int total_size;
|
int total_size;
|
||||||
z_stream d_stream;
|
z_stream d_stream;
|
||||||
@ -97,8 +97,7 @@ static int csw_cas_to_wav_size( const UINT8 *casdata, int caslen )
|
|||||||
//from here on down for now I am assuming it is compressed csw file.
|
//from here on down for now I am assuming it is compressed csw file.
|
||||||
in_ptr = (UINT8*) casdata+0x34+HeaderExtensionLength;
|
in_ptr = (UINT8*) casdata+0x34+HeaderExtensionLength;
|
||||||
|
|
||||||
gz_ptr = (UINT8*)malloc( 8 );
|
gz_ptr.resize( 8 );
|
||||||
|
|
||||||
|
|
||||||
d_stream.next_in = (unsigned char *)in_ptr;
|
d_stream.next_in = (unsigned char *)in_ptr;
|
||||||
d_stream.avail_in = caslen - ( in_ptr - casdata );
|
d_stream.avail_in = caslen - ( in_ptr - casdata );
|
||||||
@ -155,20 +154,9 @@ static int csw_cas_to_wav_size( const UINT8 *casdata, int caslen )
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gz_ptr )
|
|
||||||
{
|
|
||||||
free( gz_ptr );
|
|
||||||
gz_ptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return total_size;
|
return total_size;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if ( gz_ptr )
|
|
||||||
{
|
|
||||||
free( gz_ptr );
|
|
||||||
gz_ptr = NULL;
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +169,7 @@ static int csw_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
|
|||||||
UINT8 HeaderExtensionLength;
|
UINT8 HeaderExtensionLength;
|
||||||
INT8 Bit;
|
INT8 Bit;
|
||||||
|
|
||||||
UINT8 *gz_ptr = NULL;
|
dynamic_buffer gz_ptr;
|
||||||
int total_size;
|
int total_size;
|
||||||
z_stream d_stream;
|
z_stream d_stream;
|
||||||
int err;
|
int err;
|
||||||
@ -217,7 +205,7 @@ static int csw_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
|
|||||||
//from here on down for now I am assuming it is compressed csw file.
|
//from here on down for now I am assuming it is compressed csw file.
|
||||||
in_ptr = (UINT8*) bytes+0x34+HeaderExtensionLength;
|
in_ptr = (UINT8*) bytes+0x34+HeaderExtensionLength;
|
||||||
|
|
||||||
gz_ptr = (UINT8*)malloc( 8 );
|
gz_ptr.resize( 8 );
|
||||||
|
|
||||||
d_stream.next_in = (unsigned char *)in_ptr;
|
d_stream.next_in = (unsigned char *)in_ptr;
|
||||||
d_stream.avail_in = mycaslen - ( in_ptr - bytes );
|
d_stream.avail_in = mycaslen - ( in_ptr - bytes );
|
||||||
@ -278,20 +266,9 @@ static int csw_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gz_ptr )
|
|
||||||
{
|
|
||||||
free( gz_ptr );
|
|
||||||
gz_ptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if ( gz_ptr )
|
|
||||||
{
|
|
||||||
free( gz_ptr );
|
|
||||||
gz_ptr = NULL;
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ static int kc_handle_tap(INT16 *buffer, const UINT8 *casdata)
|
|||||||
|
|
||||||
static int kc_handle_sss(INT16 *buffer, const UINT8 *casdata)
|
static int kc_handle_sss(INT16 *buffer, const UINT8 *casdata)
|
||||||
{
|
{
|
||||||
UINT8 *sss = (UINT8*)malloc(kc_image_size + 11);
|
dynamic_buffer sss(kc_image_size + 11);
|
||||||
|
|
||||||
// tries to generate the missing head
|
// tries to generate the missing head
|
||||||
memset(sss + 0, 0xd3, 3);
|
memset(sss + 0, 0xd3, 3);
|
||||||
@ -222,8 +222,6 @@ static int kc_handle_sss(INT16 *buffer, const UINT8 *casdata)
|
|||||||
|
|
||||||
int retval = kc_handle_cass(buffer, sss, KC_IMAGE_KCC);
|
int retval = kc_handle_cass(buffer, sss, KC_IMAGE_KCC);
|
||||||
|
|
||||||
free(sss);
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1647,9 +1647,8 @@ static floperr_t ti99_sdf_write_track(floppy_image_legacy *floppy, int head, int
|
|||||||
*/
|
*/
|
||||||
/* static floperr_t ti99_sdf_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params)
|
/* static floperr_t ti99_sdf_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params)
|
||||||
{
|
{
|
||||||
UINT8 *sector0 = (UINT8*)malloc(SECTOR_SIZE);
|
dynamic_buffer sector0(SECTOR_SIZE);
|
||||||
create_vib(sector0, params);
|
create_vib(sector0, params);
|
||||||
free(sector0);
|
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
printf("not implemented\n");
|
printf("not implemented\n");
|
||||||
@ -2297,11 +2296,9 @@ static floperr_t ti99_tdf_read_sector(floppy_image_legacy *floppy, int head, int
|
|||||||
{
|
{
|
||||||
floperr_t err;
|
floperr_t err;
|
||||||
UINT8 *sector_data;
|
UINT8 *sector_data;
|
||||||
UINT8 *track_data;
|
|
||||||
int imgtrack = track;
|
int imgtrack = track;
|
||||||
struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy);
|
struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy);
|
||||||
|
dynamic_buffer track_data(tag->track_size);
|
||||||
track_data = (UINT8*)malloc(tag->track_size);
|
|
||||||
|
|
||||||
if (use_80_track_drives && tag->tracks<=40)
|
if (use_80_track_drives && tag->tracks<=40)
|
||||||
{
|
{
|
||||||
@ -2318,7 +2315,6 @@ static floperr_t ti99_tdf_read_sector(floppy_image_legacy *floppy, int head, int
|
|||||||
/* verify CRC? */
|
/* verify CRC? */
|
||||||
|
|
||||||
memcpy(buffer, sector_data, SECTOR_SIZE);
|
memcpy(buffer, sector_data, SECTOR_SIZE);
|
||||||
free(track_data);
|
|
||||||
return FLOPPY_ERROR_SUCCESS;
|
return FLOPPY_ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2376,7 +2372,7 @@ static floperr_t ti99_tdf_write_indexed_sector(floppy_image_legacy *floppy, int
|
|||||||
/* Read track, head */
|
/* Read track, head */
|
||||||
int byte;
|
int byte;
|
||||||
struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy);
|
struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy);
|
||||||
UINT8 *track_data;
|
dynamic_buffer track_data(tag->track_size);
|
||||||
UINT8 *sector_data;
|
UINT8 *sector_data;
|
||||||
UINT64 track_offset;
|
UINT64 track_offset;
|
||||||
UINT64 offset;
|
UINT64 offset;
|
||||||
@ -2388,8 +2384,6 @@ static floperr_t ti99_tdf_write_indexed_sector(floppy_image_legacy *floppy, int
|
|||||||
int i;
|
int i;
|
||||||
floperr_t err;
|
floperr_t err;
|
||||||
|
|
||||||
track_data = (UINT8*)malloc(tag->track_size);
|
|
||||||
|
|
||||||
if (use_80_track_drives && tag->tracks<=40)
|
if (use_80_track_drives && tag->tracks<=40)
|
||||||
{
|
{
|
||||||
imgtrack = track / 2;
|
imgtrack = track / 2;
|
||||||
@ -2398,7 +2392,6 @@ static floperr_t ti99_tdf_write_indexed_sector(floppy_image_legacy *floppy, int
|
|||||||
err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, track_data, tag->track_size);
|
err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, track_data, tag->track_size);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
free(track_data);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2407,7 +2400,6 @@ static floperr_t ti99_tdf_write_indexed_sector(floppy_image_legacy *floppy, int
|
|||||||
{
|
{
|
||||||
if (determine_offset(tag->format, track_data, &tag->first_idam)==FLOPPY_ERROR_SEEKERROR)
|
if (determine_offset(tag->format, track_data, &tag->first_idam)==FLOPPY_ERROR_SEEKERROR)
|
||||||
{
|
{
|
||||||
free(track_data);
|
|
||||||
return FLOPPY_ERROR_SEEKERROR;
|
return FLOPPY_ERROR_SEEKERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2428,7 +2420,6 @@ static floperr_t ti99_tdf_write_indexed_sector(floppy_image_legacy *floppy, int
|
|||||||
/* Not that many sectors in this track? */
|
/* Not that many sectors in this track? */
|
||||||
if (sector_index>0)
|
if (sector_index>0)
|
||||||
{
|
{
|
||||||
free(track_data);
|
|
||||||
return FLOPPY_ERROR_SEEKERROR;
|
return FLOPPY_ERROR_SEEKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2445,7 +2436,6 @@ static floperr_t ti99_tdf_write_indexed_sector(floppy_image_legacy *floppy, int
|
|||||||
/* There was no DAM. Image seems to be broken. */
|
/* There was no DAM. Image seems to be broken. */
|
||||||
if (i == tag->track_size)
|
if (i == tag->track_size)
|
||||||
{
|
{
|
||||||
free(track_data);
|
|
||||||
return FLOPPY_ERROR_SEEKERROR;
|
return FLOPPY_ERROR_SEEKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2469,9 +2459,6 @@ static floperr_t ti99_tdf_write_indexed_sector(floppy_image_legacy *floppy, int
|
|||||||
crc_field[1] = (crc & 0xff);
|
crc_field[1] = (crc & 0xff);
|
||||||
floppy_image_write(floppy, crc_field, offset+SECTOR_SIZE, 2);
|
floppy_image_write(floppy, crc_field, offset+SECTOR_SIZE, 2);
|
||||||
|
|
||||||
/* Free the temporary buffer */
|
|
||||||
free(track_data);
|
|
||||||
|
|
||||||
return FLOPPY_ERROR_SUCCESS;
|
return FLOPPY_ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2481,12 +2468,11 @@ static floperr_t ti99_tdf_find_indexed_sector(floppy_image_legacy *floppy, int h
|
|||||||
/* Read track, head */
|
/* Read track, head */
|
||||||
int byte = 0;
|
int byte = 0;
|
||||||
struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy);
|
struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy);
|
||||||
UINT8 *track_data;
|
dynamic_buffer track_data(tag->track_size);
|
||||||
int imgtrack = track;
|
int imgtrack = track;
|
||||||
int i;
|
int i;
|
||||||
floperr_t err;
|
floperr_t err;
|
||||||
floperr_t retval;
|
floperr_t retval;
|
||||||
track_data = (UINT8*)malloc(tag->track_size);
|
|
||||||
|
|
||||||
if (use_80_track_drives && tag->tracks<=40)
|
if (use_80_track_drives && tag->tracks<=40)
|
||||||
{
|
{
|
||||||
@ -2496,7 +2482,6 @@ static floperr_t ti99_tdf_find_indexed_sector(floppy_image_legacy *floppy, int h
|
|||||||
err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, track_data, tag->track_size);
|
err = ti99_tdf_read_track_internal(floppy, head, imgtrack, 0, track_data, tag->track_size);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
free(track_data);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2506,7 +2491,6 @@ static floperr_t ti99_tdf_find_indexed_sector(floppy_image_legacy *floppy, int h
|
|||||||
{
|
{
|
||||||
if (determine_offset(tag->format, track_data, &tag->first_idam)==FLOPPY_ERROR_SEEKERROR)
|
if (determine_offset(tag->format, track_data, &tag->first_idam)==FLOPPY_ERROR_SEEKERROR)
|
||||||
{
|
{
|
||||||
free(track_data);
|
|
||||||
return FLOPPY_ERROR_SEEKERROR;
|
return FLOPPY_ERROR_SEEKERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2572,7 +2556,6 @@ static floperr_t ti99_tdf_find_indexed_sector(floppy_image_legacy *floppy, int h
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(track_data);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2626,7 +2609,8 @@ static int ti99_tdf_guess_geometry(floppy_image_legacy *floppy, UINT64 size,
|
|||||||
{
|
{
|
||||||
int idamcnt, state, track, head, i, totalseclen = 0, format = 0, byte, tracklength, trackadd = 0;
|
int idamcnt, state, track, head, i, totalseclen = 0, format = 0, byte, tracklength, trackadd = 0;
|
||||||
int first_idam = 0;
|
int first_idam = 0;
|
||||||
UINT8 *track_data;
|
/* Allocate enough bytes to hold the longest supported track. */
|
||||||
|
dynamic_buffer track_data(13000);
|
||||||
/*int offset;*/
|
/*int offset;*/
|
||||||
|
|
||||||
struct ti99dsk_geometry dummy_geometry;
|
struct ti99dsk_geometry dummy_geometry;
|
||||||
@ -2636,8 +2620,6 @@ static int ti99_tdf_guess_geometry(floppy_image_legacy *floppy, UINT64 size,
|
|||||||
else
|
else
|
||||||
geometry = &dummy_geometry;
|
geometry = &dummy_geometry;
|
||||||
|
|
||||||
/* Allocate enough bytes to hold the longest supported track. */
|
|
||||||
track_data = (UINT8*)malloc(13000);
|
|
||||||
floppy_image_read(floppy, track_data, 0, 13000);
|
floppy_image_read(floppy, track_data, 0, 13000);
|
||||||
|
|
||||||
if (determine_offset(TI99_MFM, track_data, &first_idam)==FLOPPY_ERROR_SEEKERROR)
|
if (determine_offset(TI99_MFM, track_data, &first_idam)==FLOPPY_ERROR_SEEKERROR)
|
||||||
@ -2652,7 +2634,6 @@ static int ti99_tdf_guess_geometry(floppy_image_legacy *floppy, UINT64 size,
|
|||||||
// We only give a moderate vote in this case, so SDF
|
// We only give a moderate vote in this case, so SDF
|
||||||
// make take it.
|
// make take it.
|
||||||
|
|
||||||
free(track_data);
|
|
||||||
if (size < 130120 || size > 2078720)
|
if (size < 130120 || size > 2078720)
|
||||||
{
|
{
|
||||||
LOG_FORMATS("Unknown format size: %d\n", (int)size);
|
LOG_FORMATS("Unknown format size: %d\n", (int)size);
|
||||||
@ -2794,7 +2775,6 @@ static int ti99_tdf_guess_geometry(floppy_image_legacy *floppy, UINT64 size,
|
|||||||
{
|
{
|
||||||
/* error ... what now? */
|
/* error ... what now? */
|
||||||
LOG_FORMATS("Error when reading last track. Image broken.\n");
|
LOG_FORMATS("Error when reading last track. Image broken.\n");
|
||||||
free(track_data);
|
|
||||||
return 50;
|
return 50;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2824,11 +2804,9 @@ static int ti99_tdf_guess_geometry(floppy_image_legacy *floppy, UINT64 size,
|
|||||||
if (geometry->tracksperside < 35 || geometry->tracksperside > 80)
|
if (geometry->tracksperside < 35 || geometry->tracksperside > 80)
|
||||||
{
|
{
|
||||||
LOG_FORMATS("Unsupported track count: %d\n", geometry->tracksperside);
|
LOG_FORMATS("Unsupported track count: %d\n", geometry->tracksperside);
|
||||||
free(track_data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(track_data);
|
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "z80ne_dsk.h"
|
#include "z80ne_dsk.h"
|
||||||
#include "basicdsk.h"
|
#include "basicdsk.h"
|
||||||
#include "imageutl.h"
|
#include "imageutl.h"
|
||||||
|
#include "coretmpl.h"
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
* DMK file format
|
* DMK file format
|
||||||
@ -175,8 +176,8 @@ static floperr_t z80ne_dmk_format_track(floppy_image_legacy *floppy, int head, i
|
|||||||
UINT8 *track_data;
|
UINT8 *track_data;
|
||||||
void *track_data_v;
|
void *track_data_v;
|
||||||
UINT32 max_track_size;
|
UINT32 max_track_size;
|
||||||
int *sector_map = NULL;
|
dynamic_array<int> sector_map;
|
||||||
UINT8 *local_sector = NULL;
|
dynamic_buffer local_sector;
|
||||||
int local_sector_size;
|
int local_sector_size;
|
||||||
int sector_position;
|
int sector_position;
|
||||||
int i;
|
int i;
|
||||||
@ -206,13 +207,8 @@ static floperr_t z80ne_dmk_format_track(floppy_image_legacy *floppy, int head, i
|
|||||||
track_data = (UINT8 *) track_data_v;
|
track_data = (UINT8 *) track_data_v;
|
||||||
|
|
||||||
/* set up sector map */
|
/* set up sector map */
|
||||||
sector_map = (int*)malloc(sectors * sizeof(*sector_map));
|
sector_map.resize(sectors);
|
||||||
if (!sector_map)
|
sector_map.clear(0xFF);
|
||||||
{
|
|
||||||
err = FLOPPY_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
memset(sector_map, 0xFF, sectors * sizeof(*sector_map));
|
|
||||||
|
|
||||||
physical_sector = 0;
|
physical_sector = 0;
|
||||||
for (logical_sector = 0; logical_sector < sectors; logical_sector++)
|
for (logical_sector = 0; logical_sector < sectors; logical_sector++)
|
||||||
@ -235,13 +231,8 @@ static floperr_t z80ne_dmk_format_track(floppy_image_legacy *floppy, int head, i
|
|||||||
sector_length +
|
sector_length +
|
||||||
DMK_DATA_CRC_LEN +
|
DMK_DATA_CRC_LEN +
|
||||||
DMK_DATA_GAP_LEN);
|
DMK_DATA_GAP_LEN);
|
||||||
local_sector = (UINT8*)malloc(local_sector_size);
|
local_sector.resize(local_sector_size);
|
||||||
if (!local_sector)
|
local_sector.clear();
|
||||||
{
|
|
||||||
err = FLOPPY_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
memset(local_sector, 0x00, local_sector_size);
|
|
||||||
|
|
||||||
/* set up track table of contents */
|
/* set up track table of contents */
|
||||||
physical_sector = 0;
|
physical_sector = 0;
|
||||||
@ -326,11 +317,6 @@ static floperr_t z80ne_dmk_format_track(floppy_image_legacy *floppy, int head, i
|
|||||||
memset(&track_data[track_position], 0xFF, max_track_size - track_position);
|
memset(&track_data[track_position], 0xFF, max_track_size - track_position);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (sector_map)
|
|
||||||
free(sector_map);
|
|
||||||
if (local_sector)
|
|
||||||
free(local_sector);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +378,7 @@ static floperr_t z80ne_dmk_seek_sector_in_track(floppy_image_legacy *floppy, int
|
|||||||
void *track_data_v;
|
void *track_data_v;
|
||||||
size_t track_length;
|
size_t track_length;
|
||||||
size_t sec_len;
|
size_t sec_len;
|
||||||
UINT8 *local_idam = NULL;
|
dynamic_buffer local_idam;
|
||||||
int local_idam_size;
|
int local_idam_size;
|
||||||
UINT8 *sec_data;
|
UINT8 *sec_data;
|
||||||
|
|
||||||
@ -406,13 +392,8 @@ static floperr_t z80ne_dmk_seek_sector_in_track(floppy_image_legacy *floppy, int
|
|||||||
DMK_ID_GAP_LEN +
|
DMK_ID_GAP_LEN +
|
||||||
DMK_DAM_LEN +
|
DMK_DAM_LEN +
|
||||||
DMK_DATA_GAP_LEN);
|
DMK_DATA_GAP_LEN);
|
||||||
local_idam = (UINT8*)malloc(local_idam_size);
|
local_idam.resize(local_idam_size);
|
||||||
if (!local_idam)
|
local_idam.clear();
|
||||||
{
|
|
||||||
err = FLOPPY_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
memset(local_idam, 0x00, local_idam_size);
|
|
||||||
|
|
||||||
/* search for matching IDAM */
|
/* search for matching IDAM */
|
||||||
for (i = 0; i < DMK_TOC_LEN / 2; i++)
|
for (i = 0; i < DMK_TOC_LEN / 2; i++)
|
||||||
@ -509,8 +490,6 @@ static floperr_t z80ne_dmk_seek_sector_in_track(floppy_image_legacy *floppy, int
|
|||||||
if (sector_length)
|
if (sector_length)
|
||||||
*sector_length = sec_len;
|
*sector_length = sec_len;
|
||||||
done:
|
done:
|
||||||
if (local_idam)
|
|
||||||
free(local_idam);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,7 +561,7 @@ static floperr_t internal_z80ne_dmk_read_sector(floppy_image_legacy *floppy, int
|
|||||||
UINT16 crc_on_disk;
|
UINT16 crc_on_disk;
|
||||||
UINT16 calculated_crc;
|
UINT16 calculated_crc;
|
||||||
UINT8 *sector_data = NULL;
|
UINT8 *sector_data = NULL;
|
||||||
UINT8 *local_sector = NULL;
|
dynamic_buffer local_sector;
|
||||||
int local_sector_size;
|
int local_sector_size;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -593,13 +572,8 @@ static floperr_t internal_z80ne_dmk_read_sector(floppy_image_legacy *floppy, int
|
|||||||
|
|
||||||
/* set up a local physical sector space (DAM + data + crc + GAP) */
|
/* set up a local physical sector space (DAM + data + crc + GAP) */
|
||||||
local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
||||||
local_sector = (UINT8*)malloc(local_sector_size);
|
local_sector.resize(local_sector_size);
|
||||||
if (!local_sector)
|
local_sector.clear();
|
||||||
{
|
|
||||||
err = FLOPPY_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
memset(local_sector, 0x00, local_sector_size);
|
|
||||||
|
|
||||||
/* get sector data */
|
/* get sector data */
|
||||||
/* create a local copy of sector data including DAM (for crc calculation) */
|
/* create a local copy of sector data including DAM (for crc calculation) */
|
||||||
@ -622,8 +596,6 @@ static floperr_t internal_z80ne_dmk_read_sector(floppy_image_legacy *floppy, int
|
|||||||
memcpy(buffer, local_sector+1, MIN(sector_length, buflen));
|
memcpy(buffer, local_sector+1, MIN(sector_length, buflen));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (local_sector)
|
|
||||||
free(local_sector);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,7 +607,7 @@ static floperr_t internal_z80ne_dmk_write_sector(floppy_image_legacy *floppy, in
|
|||||||
UINT32 sector_length;
|
UINT32 sector_length;
|
||||||
UINT8 *sector_data;
|
UINT8 *sector_data;
|
||||||
UINT16 crc;
|
UINT16 crc;
|
||||||
UINT8 *local_sector = NULL;
|
dynamic_buffer local_sector;
|
||||||
int local_sector_size;
|
int local_sector_size;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -646,13 +618,8 @@ static floperr_t internal_z80ne_dmk_write_sector(floppy_image_legacy *floppy, in
|
|||||||
|
|
||||||
/* set up a local physical sector space */
|
/* set up a local physical sector space */
|
||||||
local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
||||||
local_sector = (UINT8*)malloc(local_sector_size);
|
local_sector.resize(local_sector_size);
|
||||||
if (!local_sector)
|
local_sector.clear();
|
||||||
{
|
|
||||||
err = FLOPPY_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
memset(local_sector, 0x00, local_sector_size);
|
|
||||||
if(!ddam)
|
if(!ddam)
|
||||||
local_sector[0] = 0xFB;
|
local_sector[0] = 0xFB;
|
||||||
else
|
else
|
||||||
@ -677,8 +644,6 @@ static floperr_t internal_z80ne_dmk_write_sector(floppy_image_legacy *floppy, in
|
|||||||
sector_data[i*2] = sector_data[(i*2)+1] = local_sector[i];
|
sector_data[i*2] = sector_data[(i*2)+1] = local_sector[i];
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (local_sector)
|
|
||||||
free(local_sector);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,16 +310,11 @@ static imgtoolerr_t imgtool_floppy_transfer_sector_tofrom_stream(imgtool_image *
|
|||||||
{
|
{
|
||||||
floperr_t err;
|
floperr_t err;
|
||||||
floppy_image_legacy *floppy;
|
floppy_image_legacy *floppy;
|
||||||
void *buffer = NULL;
|
dynamic_buffer buffer;
|
||||||
|
|
||||||
floppy = imgtool_floppy(img);
|
floppy = imgtool_floppy(img);
|
||||||
|
|
||||||
buffer = malloc(length);
|
buffer.resize(length);
|
||||||
if (!buffer)
|
|
||||||
{
|
|
||||||
err = FLOPPY_ERROR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (direction)
|
if (direction)
|
||||||
{
|
{
|
||||||
@ -339,8 +334,6 @@ static imgtoolerr_t imgtool_floppy_transfer_sector_tofrom_stream(imgtool_image *
|
|||||||
err = FLOPPY_ERROR_SUCCESS;
|
err = FLOPPY_ERROR_SUCCESS;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (buffer)
|
|
||||||
free(buffer);
|
|
||||||
return imgtool_floppy_error(err);
|
return imgtool_floppy_error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ static imgtoolerr_t map_chd_error(chd_error chderr)
|
|||||||
imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen)
|
imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen)
|
||||||
{
|
{
|
||||||
imgtoolerr_t err = IMGTOOLERR_SUCCESS;
|
imgtoolerr_t err = IMGTOOLERR_SUCCESS;
|
||||||
UINT8 *cache = NULL;
|
dynamic_buffer cache;
|
||||||
chd_file chd;
|
chd_file chd;
|
||||||
chd_error rc;
|
chd_error rc;
|
||||||
UINT64 logicalbytes;
|
UINT64 logicalbytes;
|
||||||
@ -101,13 +101,8 @@ imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylind
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* alloc and zero buffer */
|
/* alloc and zero buffer */
|
||||||
cache = (UINT8*)malloc(hunksize);
|
cache.resize(hunksize);
|
||||||
if (!cache)
|
cache.clear();
|
||||||
{
|
|
||||||
err = IMGTOOLERR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
memset(cache, '\0', hunksize);
|
|
||||||
|
|
||||||
/* zero out every hunk */
|
/* zero out every hunk */
|
||||||
totalhunks = (logicalbytes + hunksize - 1) / hunksize;
|
totalhunks = (logicalbytes + hunksize - 1) / hunksize;
|
||||||
@ -121,10 +116,7 @@ imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylind
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (cache)
|
|
||||||
free(cache);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ static int cmd_readsector(const struct command *c, int argc, char *argv[])
|
|||||||
imgtoolerr_t err;
|
imgtoolerr_t err;
|
||||||
imgtool_image *img;
|
imgtool_image *img;
|
||||||
imgtool_stream *stream = NULL;
|
imgtool_stream *stream = NULL;
|
||||||
void *buffer = NULL;
|
dynamic_buffer buffer;
|
||||||
UINT32 size, track, head, sector;
|
UINT32 size, track, head, sector;
|
||||||
|
|
||||||
/* attempt to open image */
|
/* attempt to open image */
|
||||||
@ -641,12 +641,7 @@ static int cmd_readsector(const struct command *c, int argc, char *argv[])
|
|||||||
if (err)
|
if (err)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
buffer = malloc(size);
|
buffer.resize(size);
|
||||||
if (!buffer)
|
|
||||||
{
|
|
||||||
err = IMGTOOLERR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = imgtool_image_read_sector(img, track, head, sector, buffer, size);
|
err = imgtool_image_read_sector(img, track, head, sector, buffer, size);
|
||||||
if (err)
|
if (err)
|
||||||
@ -663,8 +658,6 @@ static int cmd_readsector(const struct command *c, int argc, char *argv[])
|
|||||||
stream_write(stream, buffer, size);
|
stream_write(stream, buffer, size);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (buffer)
|
|
||||||
free(buffer);
|
|
||||||
if (stream)
|
if (stream)
|
||||||
stream_close(stream);
|
stream_close(stream);
|
||||||
if (err)
|
if (err)
|
||||||
@ -679,7 +672,7 @@ static int cmd_writesector(const struct command *c, int argc, char *argv[])
|
|||||||
imgtoolerr_t err;
|
imgtoolerr_t err;
|
||||||
imgtool_image *img;
|
imgtool_image *img;
|
||||||
imgtool_stream *stream = NULL;
|
imgtool_stream *stream = NULL;
|
||||||
void *buffer = NULL;
|
dynamic_buffer buffer;
|
||||||
UINT32 size, track, head, sector;
|
UINT32 size, track, head, sector;
|
||||||
|
|
||||||
/* attempt to open image */
|
/* attempt to open image */
|
||||||
@ -700,12 +693,7 @@ static int cmd_writesector(const struct command *c, int argc, char *argv[])
|
|||||||
|
|
||||||
size = (UINT32) stream_size(stream);
|
size = (UINT32) stream_size(stream);
|
||||||
|
|
||||||
buffer = malloc(size);
|
buffer.resize(size);
|
||||||
if (!buffer)
|
|
||||||
{
|
|
||||||
err = (imgtoolerr_t)(IMGTOOLERR_OUTOFMEMORY);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream_read(stream, buffer, size);
|
stream_read(stream, buffer, size);
|
||||||
|
|
||||||
@ -714,8 +702,6 @@ static int cmd_writesector(const struct command *c, int argc, char *argv[])
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (buffer)
|
|
||||||
free(buffer);
|
|
||||||
if (stream)
|
if (stream)
|
||||||
stream_close(stream);
|
stream_close(stream);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -711,7 +711,7 @@ static imgtoolerr_t os9_diskimage_open(imgtool_image *image, imgtool_stream *str
|
|||||||
static imgtoolerr_t os9_diskimage_create(imgtool_image *img, imgtool_stream *stream, option_resolution *opts)
|
static imgtoolerr_t os9_diskimage_create(imgtool_image *img, imgtool_stream *stream, option_resolution *opts)
|
||||||
{
|
{
|
||||||
imgtoolerr_t err;
|
imgtoolerr_t err;
|
||||||
UINT8 *header;
|
dynamic_buffer header;
|
||||||
UINT32 heads, tracks, sectors, sector_bytes, first_sector_id;
|
UINT32 heads, tracks, sectors, sector_bytes, first_sector_id;
|
||||||
UINT32 cluster_size, owner_id;
|
UINT32 cluster_size, owner_id;
|
||||||
UINT32 allocation_bitmap_bits, allocation_bitmap_lsns;
|
UINT32 allocation_bitmap_bits, allocation_bitmap_lsns;
|
||||||
@ -732,12 +732,7 @@ static imgtoolerr_t os9_diskimage_create(imgtool_image *img, imgtool_stream *str
|
|||||||
first_sector_id = option_resolution_lookup_int(opts, 'F');
|
first_sector_id = option_resolution_lookup_int(opts, 'F');
|
||||||
title = "";
|
title = "";
|
||||||
|
|
||||||
header = (UINT8*)malloc(sector_bytes);
|
header.resize(sector_bytes);
|
||||||
if (!header)
|
|
||||||
{
|
|
||||||
err = IMGTOOLERR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sector_bytes > 256)
|
if (sector_bytes > 256)
|
||||||
sector_bytes = 256;
|
sector_bytes = 256;
|
||||||
@ -845,8 +840,6 @@ static imgtoolerr_t os9_diskimage_create(imgtool_image *img, imgtool_stream *str
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (header)
|
|
||||||
free(header);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1037,7 +1030,7 @@ static imgtoolerr_t os9_diskimage_writefile(imgtool_partition *partition, const
|
|||||||
imgtool_image *image = imgtool_partition_image(partition);
|
imgtool_image *image = imgtool_partition_image(partition);
|
||||||
struct os9_fileinfo file_info;
|
struct os9_fileinfo file_info;
|
||||||
size_t write_size;
|
size_t write_size;
|
||||||
void *buf = NULL;
|
dynamic_buffer buf;
|
||||||
int i = -1;
|
int i = -1;
|
||||||
UINT32 lsn = 0;
|
UINT32 lsn = 0;
|
||||||
UINT32 count = 0;
|
UINT32 count = 0;
|
||||||
@ -1046,12 +1039,7 @@ static imgtoolerr_t os9_diskimage_writefile(imgtool_partition *partition, const
|
|||||||
|
|
||||||
disk_info = os9_get_diskinfo(image);
|
disk_info = os9_get_diskinfo(image);
|
||||||
|
|
||||||
buf = malloc(disk_info->sector_size);
|
buf.resize(disk_info->sector_size);
|
||||||
if (!buf)
|
|
||||||
{
|
|
||||||
err = IMGTOOLERR_OUTOFMEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = os9_lookup_path(image, path, CREATE_FILE, &file_info, NULL, NULL, NULL);
|
err = os9_lookup_path(image, path, CREATE_FILE, &file_info, NULL, NULL, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
@ -1086,8 +1074,6 @@ static imgtoolerr_t os9_diskimage_writefile(imgtool_partition *partition, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (buf)
|
|
||||||
free(buf);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,15 +286,13 @@ UINT16 put_odb(imgtool_stream *instream, imgtool_stream *outstream, UINT8 file_i
|
|||||||
UINT16 put_ob3(imgtool_stream *instream, imgtool_stream *outstream)
|
UINT16 put_ob3(imgtool_stream *instream, imgtool_stream *outstream)
|
||||||
{
|
{
|
||||||
UINT16 size = stream_size(instream) - 6;
|
UINT16 size = stream_size(instream) - 6;
|
||||||
UINT8 *buffer = (UINT8*)malloc(size);
|
dynamic_buffer buffer(size);
|
||||||
|
|
||||||
stream_seek(instream, 6, SEEK_SET);
|
stream_seek(instream, 6, SEEK_SET);
|
||||||
stream_read(instream, buffer, size);
|
stream_read(instream, buffer, size);
|
||||||
|
|
||||||
stream_write(outstream, buffer, size);
|
stream_write(outstream, buffer, size);
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
|
|
||||||
// end of pack
|
// end of pack
|
||||||
stream_fill(outstream, 0xff, 2);
|
stream_fill(outstream, 0xff, 2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user