diff options
author | 2009-02-28 22:10:06 +0000 | |
---|---|---|
committer | 2009-02-28 22:10:06 +0000 | |
commit | e2757c60d2fa5e74909eff1e7a48ce5841ad47e5 (patch) | |
tree | b30bddf750ef14f54e147b8d214d693af27f5d33 /src/lib/util | |
parent | 42004cf3baf9c0307775c43096df36c1d5884bf4 (diff) |
Modified the makefile to support experimental optional C++
compilation:
- new option CPP_COMPILE to trigger this (off by default)
- split CFLAGS into common, C-only, and C++-only flags
- when enabled, CPP_COMPILE causes 'pp' to be appended to
the target name
NOTE THAT THE SYSTEM CANNOT ACTUALLY BE COMPILED THIS WAY
YET. IT IS JUST AN EXPERIMENT.
Modified lib.mak to always build zlib/expat as C regardless
of CPP_COMPILE.
Modified windows.mak to fix warnings with MAXOPT=1, and to
leverage the new CFLAGs definitions.
Modified vconv.c to do appropriate conversions for new C++
options.
Updated sources so that libutil, libocore (Windows), and
libosd (Windows) can be cleanly compiled as C or C++. This
was mostly adding some casts against void *.
Fixed a few more general obvious problems at random
locations in the source:
- device->class is now device->devclass
- TYPES_COMPATIBLE uses typeid() when compiled for C++
- some functions with reserved names ('xor' in particular)
were renamed
- nested enums and structs were pulled out into separate
definitions (under C++ these would need to be scoped to
be referenced)
- TOKEN_VALUE cannot use .field=x initialization in C++ :(
Diffstat (limited to 'src/lib/util')
-rw-r--r-- | src/lib/util/astring.c | 4 | ||||
-rw-r--r-- | src/lib/util/avcomp.c | 8 | ||||
-rw-r--r-- | src/lib/util/aviio.c | 24 | ||||
-rw-r--r-- | src/lib/util/bitmap.c | 4 | ||||
-rw-r--r-- | src/lib/util/cdrom.c | 4 | ||||
-rw-r--r-- | src/lib/util/chd.c | 77 | ||||
-rw-r--r-- | src/lib/util/corefile.c | 18 | ||||
-rw-r--r-- | src/lib/util/corestr.c | 2 | ||||
-rw-r--r-- | src/lib/util/harddisk.c | 4 | ||||
-rw-r--r-- | src/lib/util/huffman.c | 4 | ||||
-rw-r--r-- | src/lib/util/jedparse.c | 10 | ||||
-rw-r--r-- | src/lib/util/options.c | 4 | ||||
-rw-r--r-- | src/lib/util/palette.c | 20 | ||||
-rw-r--r-- | src/lib/util/png.c | 16 | ||||
-rw-r--r-- | src/lib/util/pool.c | 10 | ||||
-rw-r--r-- | src/lib/util/unzip.c | 10 | ||||
-rw-r--r-- | src/lib/util/xmlfile.c | 12 |
17 files changed, 116 insertions, 115 deletions
diff --git a/src/lib/util/astring.c b/src/lib/util/astring.c index df05efaafbe..cb5d23098a3 100644 --- a/src/lib/util/astring.c +++ b/src/lib/util/astring.c @@ -65,7 +65,7 @@ INLINE int ensure_room(astring *str, int length) /* allocate a new buffer with some slop */ alloclen = length + 256; - newbuf = malloc(alloclen); + newbuf = (char *)malloc(alloclen); if (newbuf == NULL) return FALSE; @@ -124,7 +124,7 @@ astring *astring_alloc(void) astring *str; /* allocate memory; if we fail, return the dummy */ - str = malloc(sizeof(*str)); + str = (astring *)malloc(sizeof(*str)); if (str == NULL) return &dummy_astring; memset(str, 0, sizeof(*str)); diff --git a/src/lib/util/avcomp.c b/src/lib/util/avcomp.c index c42d100d888..ad3f4fefeee 100644 --- a/src/lib/util/avcomp.c +++ b/src/lib/util/avcomp.c @@ -139,7 +139,7 @@ avcomp_state *avcomp_init(UINT32 maxwidth, UINT32 maxheight, UINT32 maxchannels) return NULL; /* allocate memory for state block */ - state = malloc(sizeof(*state)); + state = (avcomp_state *)malloc(sizeof(*state)); if (state == NULL) return NULL; @@ -152,7 +152,7 @@ avcomp_state *avcomp_init(UINT32 maxwidth, UINT32 maxheight, UINT32 maxchannels) state->maxchannels = maxchannels; /* now allocate data buffers */ - state->audiodata = malloc(65536 * state->maxchannels * 2); + state->audiodata = (UINT8 *)malloc(65536 * state->maxchannels * 2); if (state->audiodata == NULL) goto cleanup; @@ -300,7 +300,7 @@ avcomp_error avcomp_encode_data(avcomp_state *state, const UINT8 *source, UINT8 videostride = width = height = 0; if (state->compress.video != NULL) { - videostart = state->compress.video->base; + videostart = (const UINT8 *)state->compress.video->base; videostride = state->compress.video->rowpixels * 2; width = state->compress.video->width; height = state->compress.video->height; @@ -455,7 +455,7 @@ avcomp_error avcomp_decode_data(avcomp_state *state, const UINT8 *source, UINT32 metastart = state->decompress.metadata; for (chnum = 0; chnum < channels; chnum++) audiostart[chnum] = (UINT8 *)state->decompress.audio[chnum]; - videostart = (state->decompress.video != NULL) ? state->decompress.video->base : NULL; + videostart = (state->decompress.video != NULL) ? (UINT8 *)state->decompress.video->base : NULL; videostride = (state->decompress.video != NULL) ? state->decompress.video->rowpixels * 2 : 0; /* data is assumed to be native-endian */ diff --git a/src/lib/util/aviio.c b/src/lib/util/aviio.c index 8a8f1cd04b6..d213d291013 100644 --- a/src/lib/util/aviio.c +++ b/src/lib/util/aviio.c @@ -374,7 +374,7 @@ INLINE avi_error set_stream_chunk_info(avi_stream *stream, UINT32 index, UINT64 if (index >= stream->chunksalloc) { UINT32 newcount = MAX(index, stream->chunksalloc + 1000); - stream->chunk = realloc(stream->chunk, newcount * sizeof(stream->chunk[0])); + stream->chunk = (avi_chunk_list *)realloc(stream->chunk, newcount * sizeof(stream->chunk[0])); if (stream->chunk == NULL) return AVIERR_NO_MEMORY; stream->chunksalloc = newcount; @@ -450,7 +450,7 @@ INLINE avi_error expand_tempbuffer(avi_file *file, UINT32 length) if (length > file->tempbuffersize) { file->tempbuffersize = 2 * length; - file->tempbuffer = realloc(file->tempbuffer, file->tempbuffersize); + file->tempbuffer = (UINT8 *)realloc(file->tempbuffer, file->tempbuffersize); if (file->tempbuffer == NULL) return AVIERR_NO_MEMORY; } @@ -475,7 +475,7 @@ avi_error avi_open(const char *filename, avi_file **file) UINT64 length; /* allocate the file */ - newfile = malloc(sizeof(*newfile)); + newfile = (avi_file *)malloc(sizeof(*newfile)); if (newfile == NULL) return AVIERR_NO_MEMORY; memset(newfile, 0, sizeof(*newfile)); @@ -541,7 +541,7 @@ avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file return AVIERR_UNSUPPORTED_AUDIO_FORMAT; /* allocate the file */ - newfile = malloc(sizeof(*newfile)); + newfile = (avi_file *)malloc(sizeof(*newfile)); if (newfile == NULL) return AVIERR_NO_MEMORY; memset(newfile, 0, sizeof(*newfile)); @@ -561,7 +561,7 @@ avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file newfile->info.audio_numsamples = 0; /* allocate two streams */ - newfile->stream = malloc(2 * sizeof(newfile->stream[0])); + newfile->stream = (avi_stream *)malloc(2 * sizeof(newfile->stream[0])); if (newfile->stream == NULL) { avierr = AVIERR_NO_MEMORY; @@ -1058,7 +1058,7 @@ static avi_error read_chunk_data(avi_file *file, const avi_chunk *chunk, UINT8 * UINT32 bytes_read; /* allocate memory for the data */ - *buffer = malloc(chunk->size); + *buffer = (UINT8 *)malloc(chunk->size); if (*buffer == NULL) return AVIERR_NO_MEMORY; @@ -1392,7 +1392,7 @@ static avi_error parse_avih_chunk(avi_file *file, avi_chunk *avih) file->streams = fetch_32bits(&chunkdata[24]); /* allocate memory for the streams */ - file->stream = malloc(sizeof(*file->stream) * file->streams); + file->stream = (avi_stream *)malloc(sizeof(*file->stream) * file->streams); if (file->stream == NULL) goto error; memset(file->stream, 0, sizeof(*file->stream) * file->streams); @@ -2044,7 +2044,7 @@ static avi_error write_indx_chunk(avi_file *file, avi_stream *stream, int initia continue; /* allocate memory */ - tempbuf = malloc(24 + 8 * chunks_this_index); + tempbuf = (UINT8 *)malloc(24 + 8 * chunks_this_index); if (tempbuf == NULL) return AVIERR_NO_MEMORY; memset(tempbuf, 0, 24 + 8 * chunks_this_index); @@ -2113,7 +2113,7 @@ static avi_error write_idx1_chunk(avi_file *file) UINT8 *tempbuf; /* allocate a temporary buffer */ - tempbuf = malloc(tempbuflength); + tempbuf = (UINT8 *)malloc(tempbuflength); if (tempbuf == NULL) return AVIERR_NO_MEMORY; @@ -2170,7 +2170,7 @@ static avi_error soundbuf_initialize(avi_file *file) file->soundbuf_samples = file->info.audio_samplerate * SOUND_BUFFER_MSEC / 1000; /* allocate a buffer */ - file->soundbuf = malloc(file->soundbuf_samples * file->info.audio_channels * sizeof(file->soundbuf[0])); + file->soundbuf = (INT16 *)malloc(file->soundbuf_samples * file->info.audio_channels * sizeof(file->soundbuf[0])); if (file->soundbuf == NULL) return AVIERR_NO_MEMORY; memset(file->soundbuf, 0, file->soundbuf_samples * file->info.audio_channels * sizeof(file->soundbuf[0])); @@ -2447,7 +2447,7 @@ static avi_error huffyuv_extract_tables(avi_stream *stream, const UINT8 *chunkda int tabnum; /* allocate memory for the data */ - stream->huffyuv = malloc(sizeof(*stream->huffyuv)); + stream->huffyuv = (huffyuv_data *)malloc(sizeof(*stream->huffyuv)); if (stream->huffyuv == NULL) { avierr = AVIERR_NO_MEMORY; @@ -2535,7 +2535,7 @@ static avi_error huffyuv_extract_tables(avi_stream *stream, const UINT8 *chunkda /* allocate the number of extra lookup tables we need */ if (bitsat16 > 0) { - table->extralookup = malloc(bitsat16 * 65536 * sizeof(table->extralookup[0])); + table->extralookup = (UINT16 *)malloc(bitsat16 * 65536 * sizeof(table->extralookup[0])); if (table->extralookup == NULL) { avierr = AVIERR_NO_MEMORY; diff --git a/src/lib/util/bitmap.c b/src/lib/util/bitmap.c index 26af203b702..5ffe709654d 100644 --- a/src/lib/util/bitmap.c +++ b/src/lib/util/bitmap.c @@ -45,7 +45,7 @@ bitmap_t *bitmap_alloc_slop(int width, int height, int xslop, int yslop, bitmap_ return NULL; /* allocate the bitmap itself */ - bitmap = malloc(sizeof(*bitmap)); + bitmap = (bitmap_t *)malloc(sizeof(*bitmap)); if (bitmap == NULL) return NULL; memset(bitmap, 0, sizeof(*bitmap)); @@ -96,7 +96,7 @@ bitmap_t *bitmap_wrap(void *base, int width, int height, int rowpixels, bitmap_f return NULL; /* allocate memory */ - bitmap = malloc(sizeof(*bitmap)); + bitmap = (bitmap_t *)malloc(sizeof(*bitmap)); if (bitmap == NULL) return NULL; memset(bitmap, 0, sizeof(*bitmap)); diff --git a/src/lib/util/cdrom.c b/src/lib/util/cdrom.c index 03427cb0a54..152c73cea4a 100644 --- a/src/lib/util/cdrom.c +++ b/src/lib/util/cdrom.c @@ -115,7 +115,7 @@ cdrom_file *cdrom_open(chd_file *chd) return NULL; /* allocate memory for the CD-ROM file */ - file = malloc(sizeof(cdrom_file)); + file = (cdrom_file *)malloc(sizeof(cdrom_file)); if (file == NULL) return NULL; @@ -163,7 +163,7 @@ cdrom_file *cdrom_open(chd_file *chd) file->cdtoc.tracks[i].chdframeofs = chdofs; /* allocate a cache */ - file->cache = malloc(chd_get_header(chd)->hunkbytes); + file->cache = (UINT8 *)malloc(chd_get_header(chd)->hunkbytes); if (file->cache == NULL) { free(file); diff --git a/src/lib/util/chd.c b/src/lib/util/chd.c index aa21bb8a1ae..5ad19c57f95 100644 --- a/src/lib/util/chd.c +++ b/src/lib/util/chd.c @@ -593,7 +593,7 @@ chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file ** EARLY_EXIT(err = CHDERR_INVALID_PARAMETER); /* allocate memory for the final result */ - newchd = malloc(sizeof(**chd)); + newchd = (chd_file *)malloc(sizeof(**chd)); if (newchd == NULL) EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY); memset(newchd, 0, sizeof(*newchd)); @@ -645,15 +645,15 @@ chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file ** EARLY_EXIT(err); /* allocate and init the hunk cache */ - newchd->cache = malloc(newchd->header.hunkbytes); - newchd->compare = malloc(newchd->header.hunkbytes); + newchd->cache = (UINT8 *)malloc(newchd->header.hunkbytes); + newchd->compare = (UINT8 *)malloc(newchd->header.hunkbytes); if (newchd->cache == NULL || newchd->compare == NULL) EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY); newchd->cachehunk = ~0; newchd->comparehunk = ~0; /* allocate the temporary compressed buffer */ - newchd->compressed = malloc(newchd->header.hunkbytes); + newchd->compressed = (UINT8 *)malloc(newchd->header.hunkbytes); if (newchd->compressed == NULL) EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY); @@ -994,7 +994,7 @@ chd_error chd_read(chd_file *chd, UINT32 hunknum, void *buffer) wait_for_pending_async(chd); /* perform the read */ - return hunk_read_into_memory(chd, hunknum, buffer); + return hunk_read_into_memory(chd, hunknum, (UINT8 *)buffer); } @@ -1048,7 +1048,7 @@ chd_error chd_write(chd_file *chd, UINT32 hunknum, const void *buffer) wait_for_pending_async(chd); /* then write out the hunk */ - return hunk_write_from_memory(chd, hunknum, buffer); + return hunk_write_from_memory(chd, hunknum, (const UINT8 *)buffer); } @@ -1105,7 +1105,7 @@ chd_error chd_async_complete(chd_file *chd) osd_work_item_release(chd->workitem); chd->workitem = NULL; - return (chd_error)result; + return (chd_error)(ptrdiff_t)result; } @@ -1291,7 +1291,7 @@ chd_error chd_clone_metadata(chd_file *source, chd_file *dest) /* otherwise, allocate a bigger temporary buffer */ else { - UINT8 *allocbuffer = malloc(metasize); + UINT8 *allocbuffer = (UINT8 *)malloc(metasize); if (allocbuffer == NULL) { err = CHDERR_OUT_OF_MEMORY; @@ -1377,7 +1377,7 @@ chd_error chd_compress_hunk(chd_file *chd, const void *data, double *curratio) return CHDERR_INVALID_STATE; /* write out the hunk */ - err = hunk_write_from_memory(chd, thishunk, data); + err = hunk_write_from_memory(chd, thishunk, (const UINT8 *)data); if (err != CHDERR_NONE) return err; @@ -1396,8 +1396,8 @@ chd_error chd_compress_hunk(chd_file *chd, const void *data, double *curratio) } if (bytestochecksum > 0) { - MD5Update(&chd->compmd5, crcdata, bytestochecksum); - sha1_update(&chd->compsha1, bytestochecksum, crcdata); + MD5Update(&chd->compmd5, (const unsigned char *)crcdata, bytestochecksum); + sha1_update(&chd->compsha1, bytestochecksum, (const UINT8 *)crcdata); } /* update our CRC map */ @@ -1594,11 +1594,11 @@ const char *chd_get_codec_name(UINT32 codec) static void *async_read_callback(void *param, int threadid) { - chd_file *chd = param; + chd_file *chd = (chd_file *)param; chd_error err; /* read the hunk into the cache */ - err = hunk_read_into_memory(chd, chd->async_hunknum, chd->async_buffer); + err = hunk_read_into_memory(chd, chd->async_hunknum, (UINT8 *)chd->async_buffer); /* return the error */ return (void *)err; @@ -1612,11 +1612,11 @@ static void *async_read_callback(void *param, int threadid) static void *async_write_callback(void *param, int threadid) { - chd_file *chd = param; + chd_file *chd = (chd_file *)param; chd_error err; /* write the hunk from memory */ - err = hunk_write_from_memory(chd, chd->async_hunknum, chd->async_buffer); + err = hunk_write_from_memory(chd, chd->async_hunknum, (const UINT8 *)chd->async_buffer); /* return the error */ return (void *)err; @@ -2131,10 +2131,11 @@ static chd_error map_read(chd_file *chd) UINT64 fileoffset, maxoffset = 0; UINT8 cookie[MAP_ENTRY_SIZE]; UINT32 count; - int i, err; + chd_error err; + int i; /* first allocate memory */ - chd->map = malloc(sizeof(chd->map[0]) * chd->header.totalhunks); + chd->map = (map_entry *)malloc(sizeof(chd->map[0]) * chd->header.totalhunks); if (!chd->map) return CHDERR_OUT_OF_MEMORY; @@ -2224,12 +2225,12 @@ static void crcmap_init(chd_file *chd, int prepopulate) chd->crctable = NULL; /* allocate a list; one for each hunk */ - chd->crcmap = malloc(chd->header.totalhunks * sizeof(chd->crcmap[0])); + chd->crcmap = (crcmap_entry *)malloc(chd->header.totalhunks * sizeof(chd->crcmap[0])); if (chd->crcmap == NULL) return; /* allocate a CRC map table */ - chd->crctable = malloc(CRCMAP_HASH_SIZE * sizeof(chd->crctable[0])); + chd->crctable = (crcmap_entry **)malloc(CRCMAP_HASH_SIZE * sizeof(chd->crctable[0])); if (chd->crctable == NULL) { free(chd->crcmap); @@ -2466,7 +2467,7 @@ static chd_error zlib_codec_init(chd_file *chd) int zerr; /* allocate memory for the 2 stream buffers */ - data = malloc(sizeof(*data)); + data = (zlib_codec_data *)malloc(sizeof(*data)); if (data == NULL) return CHDERR_OUT_OF_MEMORY; @@ -2517,7 +2518,7 @@ static chd_error zlib_codec_init(chd_file *chd) static void zlib_codec_free(chd_file *chd) { - zlib_codec_data *data = chd->codecdata; + zlib_codec_data *data = (zlib_codec_data *)chd->codecdata; /* deinit the streams */ if (data != NULL) @@ -2543,11 +2544,11 @@ static void zlib_codec_free(chd_file *chd) static chd_error zlib_codec_compress(chd_file *chd, const void *src, UINT32 *length) { - zlib_codec_data *data = chd->codecdata; + zlib_codec_data *data = (zlib_codec_data *)chd->codecdata; int zerr; /* reset the decompressor */ - data->deflater.next_in = (void *)src; + data->deflater.next_in = (Bytef *)src; data->deflater.avail_in = chd->header.hunkbytes; data->deflater.total_in = 0; data->deflater.next_out = chd->compressed; @@ -2577,14 +2578,14 @@ static chd_error zlib_codec_compress(chd_file *chd, const void *src, UINT32 *len static chd_error zlib_codec_decompress(chd_file *chd, UINT32 srclength, void *dest) { - zlib_codec_data *data = chd->codecdata; + zlib_codec_data *data = (zlib_codec_data *)chd->codecdata; int zerr; /* reset the decompressor */ data->inflater.next_in = chd->compressed; data->inflater.avail_in = srclength; data->inflater.total_in = 0; - data->inflater.next_out = dest; + data->inflater.next_out = (Bytef *)dest; data->inflater.avail_out = chd->header.hunkbytes; data->inflater.total_out = 0; zerr = inflateReset(&data->inflater); @@ -2607,7 +2608,7 @@ static chd_error zlib_codec_decompress(chd_file *chd, UINT32 srclength, void *de static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size) { - zlib_codec_data *data = opaque; + zlib_codec_data *data = (zlib_codec_data *)opaque; UINT32 *ptr; int i; @@ -2627,7 +2628,7 @@ static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size) } /* alloc a new one */ - ptr = malloc(size + sizeof(UINT32)); + ptr = (UINT32 *)malloc(size + sizeof(UINT32)); if (!ptr) return NULL; @@ -2652,7 +2653,7 @@ static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size) static void zlib_fast_free(voidpf opaque, voidpf address) { - zlib_codec_data *data = opaque; + zlib_codec_data *data = (zlib_codec_data *)opaque; UINT32 *ptr = (UINT32 *)address - 1; int i; @@ -2705,7 +2706,7 @@ static chd_error av_codec_init(chd_file *chd) av_codec_data *data; /* allocate memory for the 2 stream buffers */ - data = malloc(sizeof(*data)); + data = (av_codec_data *)malloc(sizeof(*data)); if (data == NULL) return CHDERR_OUT_OF_MEMORY; @@ -2727,7 +2728,7 @@ static chd_error av_codec_init(chd_file *chd) static void av_codec_free(chd_file *chd) { - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; /* deinit avcomp */ if (data != NULL) @@ -2746,7 +2747,7 @@ static void av_codec_free(chd_file *chd) static chd_error av_codec_compress(chd_file *chd, const void *src, UINT32 *length) { - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; int averr; int size; @@ -2761,14 +2762,14 @@ static chd_error av_codec_compress(chd_file *chd, const void *src, UINT32 *lengt /* make sure short frames are padded with 0 */ if (src != NULL) { - size = av_raw_data_size(src); + size = av_raw_data_size((const UINT8 *)src); while (size < chd->header.hunkbytes) if (((const UINT8 *)src)[size++] != 0) return CHDERR_INVALID_DATA; } /* encode the audio and video */ - averr = avcomp_encode_data(data->compstate, src, chd->compressed, length); + averr = avcomp_encode_data(data->compstate, (const UINT8 *)src, chd->compressed, length); if (averr != AVCERR_NONE || *length > chd->header.hunkbytes) return CHDERR_COMPRESSION_ERROR; @@ -2783,7 +2784,7 @@ static chd_error av_codec_compress(chd_file *chd, const void *src, UINT32 *lengt static chd_error av_codec_decompress(chd_file *chd, UINT32 srclength, void *dest) { - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; const UINT8 *source; avcomp_error averr; int size; @@ -2798,14 +2799,14 @@ static chd_error av_codec_decompress(chd_file *chd, UINT32 srclength, void *dest /* decode the audio and video */ source = chd->compressed; - averr = avcomp_decode_data(data->compstate, source, srclength, dest); + averr = avcomp_decode_data(data->compstate, source, srclength, (UINT8 *)dest); if (averr != AVCERR_NONE) return CHDERR_DECOMPRESSION_ERROR; /* pad short frames with 0 */ if (dest != NULL) { - size = av_raw_data_size(dest); + size = av_raw_data_size((const UINT8 *)dest); while (size < chd->header.hunkbytes) ((UINT8 *)dest)[size++] = 0; } @@ -2821,7 +2822,7 @@ static chd_error av_codec_decompress(chd_file *chd, UINT32 srclength, void *dest static chd_error av_codec_config(chd_file *chd, int param, void *config) { - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; /* if we're getting the compression configuration, apply it now */ if (param == AV_CODEC_COMPRESS_CONFIG) @@ -2856,7 +2857,7 @@ static chd_error av_codec_postinit(chd_file *chd) { int fps, fpsfrac, width, height, interlaced, channels, rate; UINT32 fps_times_1million, max_samples_per_frame, bytes_per_frame; - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; char metadata[256]; chd_error err; diff --git a/src/lib/util/corefile.c b/src/lib/util/corefile.c index 52aaef54ef8..94c6c410f65 100644 --- a/src/lib/util/corefile.c +++ b/src/lib/util/corefile.c @@ -127,7 +127,7 @@ file_error core_fopen(const char *filename, UINT32 openflags, core_file **file) file_error filerr = FILERR_NOT_FOUND; /* allocate the file itself */ - *file = malloc(sizeof(**file)); + *file = (core_file *)malloc(sizeof(**file)); if (*file == NULL) return FILERR_OUT_OF_MEMORY; memset(*file, 0, sizeof(**file)); @@ -161,7 +161,7 @@ static file_error core_fopen_ram_internal(const void *data, size_t length, int c return FILERR_INVALID_ACCESS; /* allocate the file itself */ - *file = malloc(sizeof(**file) + (copy_buffer ? length : 0)); + *file = (core_file *)malloc(sizeof(**file) + (copy_buffer ? length : 0)); if (*file == NULL) return FILERR_OUT_OF_MEMORY; memset(*file, 0, sizeof(**file)); @@ -284,7 +284,7 @@ file_error core_fcompress(core_file *file, int level) int zerr; /* allocate memory */ - file->zdata = malloc(sizeof(*file->zdata)); + file->zdata = (zlib_data *)malloc(sizeof(*file->zdata)); if (file->zdata == NULL) return FILERR_OUT_OF_MEMORY; memset(file->zdata, 0, sizeof(*file->zdata)); @@ -666,7 +666,7 @@ const void *core_fbuffer(core_file *file) return file->data; /* allocate some memory */ - file->data = malloc(file->length); + file->data = (UINT8 *)malloc(file->length); if (file->data == NULL) return NULL; file->data_allocated = TRUE; @@ -735,9 +735,9 @@ int core_fputs(core_file *f, const char *s) /* is this the beginning of the file? if so, write a byte order mark */ if (f->offset == 0 && !(f->openflags & OPEN_FLAG_NO_BOM)) { - *pconvbuf++ = 0xef; - *pconvbuf++ = 0xbb; - *pconvbuf++ = 0xbf; + *pconvbuf++ = (char)0xef; + *pconvbuf++ = (char)0xbb; + *pconvbuf++ = (char)0xbf; } /* convert '\n' to platform dependant line endings */ @@ -890,7 +890,7 @@ static file_error osd_or_zlib_read(core_file *file, void *buffer, UINT64 offset, return FILERR_INVALID_ACCESS; /* set up the destination */ - file->zdata->stream.next_out = buffer; + file->zdata->stream.next_out = (Bytef *)buffer; file->zdata->stream.avail_out = length; while (file->zdata->stream.avail_out != 0) { @@ -943,7 +943,7 @@ static file_error osd_or_zlib_write(core_file *file, const void *buffer, UINT64 return FILERR_INVALID_ACCESS; /* set up the source */ - file->zdata->stream.next_in = (void *)buffer; + file->zdata->stream.next_in = (Bytef *)buffer; file->zdata->stream.avail_in = length; while (file->zdata->stream.avail_in != 0) { diff --git a/src/lib/util/corestr.c b/src/lib/util/corestr.c index caedad7c0e1..c3780c9632b 100644 --- a/src/lib/util/corestr.c +++ b/src/lib/util/corestr.c @@ -112,7 +112,7 @@ char *core_strdup(const char *str) char *cpy = NULL; if (str != NULL) { - cpy = malloc(strlen(str) + 1); + cpy = (char *)malloc(strlen(str) + 1); if (cpy != NULL) strcpy(cpy, str); } diff --git a/src/lib/util/harddisk.c b/src/lib/util/harddisk.c index 0ac715d4efb..97e18a99929 100644 --- a/src/lib/util/harddisk.c +++ b/src/lib/util/harddisk.c @@ -58,7 +58,7 @@ hard_disk_file *hard_disk_open(chd_file *chd) return NULL; /* allocate memory for the hard disk file */ - file = malloc(sizeof(hard_disk_file)); + file = (hard_disk_file *)malloc(sizeof(hard_disk_file)); if (file == NULL) return NULL; @@ -72,7 +72,7 @@ hard_disk_file *hard_disk_open(chd_file *chd) file->cachehunk = -1; /* allocate a cache */ - file->cache = malloc(chd_get_header(chd)->hunkbytes); + file->cache = (UINT8 *)malloc(chd_get_header(chd)->hunkbytes); if (file->cache == NULL) { free(file); diff --git a/src/lib/util/huffman.c b/src/lib/util/huffman.c index 74be6e54ab0..2e62e9be846 100644 --- a/src/lib/util/huffman.c +++ b/src/lib/util/huffman.c @@ -424,7 +424,7 @@ huffman_error huffman_create_context(huffman_context **context, int maxbits) return HUFFERR_TOO_MANY_BITS; /* allocate a context */ - *context = malloc(sizeof(**context)); + *context = (huffman_context *)malloc(sizeof(**context)); if (*context == NULL) return HUFFERR_OUT_OF_MEMORY; @@ -1630,7 +1630,7 @@ static huffman_error build_lookup_table(huffman_context *context, UINT32 numcode /* allocate a table if needed */ if (context->lookup == NULL) - context->lookup = malloc((UINT32)sizeof(context->lookup[0]) * (UINT32)(1 << context->maxbits)); + context->lookup = (huffman_lookup_value *)malloc((UINT32)sizeof(context->lookup[0]) * (UINT32)(1 << context->maxbits)); if (context->lookup == NULL) return HUFFERR_OUT_OF_MEMORY; diff --git a/src/lib/util/jedparse.c b/src/lib/util/jedparse.c index 8e1c79de48f..1bcf1323a35 100644 --- a/src/lib/util/jedparse.c +++ b/src/lib/util/jedparse.c @@ -191,7 +191,7 @@ static void process_field(jed_data *data, const UINT8 *cursrc, const UINT8 *srce int jed_parse(const void *data, size_t length, jed_data *result) { - const UINT8 *cursrc = data; + const UINT8 *cursrc = (const UINT8 *)data; const UINT8 *srcend = cursrc + length; const UINT8 *scan; parse_info pinfo; @@ -285,7 +285,7 @@ int jed_parse(const void *data, size_t length, jed_data *result) size_t jed_output(const jed_data *data, void *result, size_t length) { - UINT8 *curdst = result; + UINT8 *curdst = (UINT8 *)result; UINT8 *dstend = curdst + length; int i, zeros, ones; char tempbuf[256]; @@ -357,7 +357,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length) /* now compute the transmission checksum */ checksum = 0; - for (temp = result; temp < curdst && temp < dstend; temp++) + for (temp = (UINT8 *)result; temp < curdst && temp < dstend; temp++) checksum += *temp & 0x7f; checksum += 0x03; @@ -381,7 +381,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length) int jedbin_parse(const void *data, size_t length, jed_data *result) { - const UINT8 *cursrc = data; + const UINT8 *cursrc = (const UINT8 *)data; /* initialize the output */ memset(result, 0, sizeof(*result)); @@ -414,7 +414,7 @@ int jedbin_parse(const void *data, size_t length, jed_data *result) size_t jedbin_output(const jed_data *data, void *result, size_t length) { - UINT8 *curdst = result; + UINT8 *curdst = (UINT8 *)result; /* ensure we have enough room */ if (length >= 4 + (data->numfuses + 7) / 8) diff --git a/src/lib/util/options.c b/src/lib/util/options.c index bb4f9132c89..3d1673fd0d2 100644 --- a/src/lib/util/options.c +++ b/src/lib/util/options.c @@ -289,7 +289,7 @@ int options_add_entries(core_options *opts, const options_entry *entrylist) int i; /* allocate a new item */ - options_data *data = malloc(sizeof(*data)); + options_data *data = (options_data *)malloc(sizeof(*data)); if (data == NULL) return FALSE; memset(data, 0, sizeof(*data)); @@ -845,7 +845,7 @@ options_enumerator *options_enumerator_begin(core_options *opts) options_enumerator *enumerator; /* allocate memory for the enumerator */ - enumerator = malloc(sizeof(*enumerator)); + enumerator = (options_enumerator *)malloc(sizeof(*enumerator)); if (enumerator == NULL) return NULL; diff --git a/src/lib/util/palette.c b/src/lib/util/palette.c index e553157d614..e0854d820eb 100644 --- a/src/lib/util/palette.c +++ b/src/lib/util/palette.c @@ -107,7 +107,7 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) UINT32 index; /* allocate memory */ - palette = malloc(sizeof(*palette)); + palette = (palette_t *)malloc(sizeof(*palette)); if (palette == NULL) goto error; memset(palette, 0, sizeof(*palette)); @@ -120,8 +120,8 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) palette->gamma_map[index] = index; /* allocate an array of palette entries and individual contrasts for each */ - palette->entry_color = malloc(sizeof(*palette->entry_color) * numcolors); - palette->entry_contrast = malloc(sizeof(*palette->entry_contrast) * numcolors); + palette->entry_color = (rgb_t *)malloc(sizeof(*palette->entry_color) * numcolors); + palette->entry_contrast = (float *)malloc(sizeof(*palette->entry_contrast) * numcolors); if (palette->entry_color == NULL || palette->entry_contrast == NULL) goto error; @@ -133,8 +133,8 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) } /* allocate an array of brightness and contrast for each group */ - palette->group_bright = malloc(sizeof(*palette->group_bright) * numgroups); - palette->group_contrast = malloc(sizeof(*palette->group_contrast) * numgroups); + palette->group_bright = (float *)malloc(sizeof(*palette->group_bright) * numgroups); + palette->group_contrast = (float *)malloc(sizeof(*palette->group_contrast) * numgroups); if (palette->group_bright == NULL || palette->group_contrast == NULL) goto error; @@ -146,8 +146,8 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) } /* allocate arrays for the adjusted colors */ - palette->adjusted_color = malloc(sizeof(*palette->adjusted_color) * (numcolors * numgroups + 2)); - palette->adjusted_rgb15 = malloc(sizeof(*palette->adjusted_rgb15) * (numcolors * numgroups + 2)); + palette->adjusted_color = (rgb_t *)malloc(sizeof(*palette->adjusted_color) * (numcolors * numgroups + 2)); + palette->adjusted_rgb15 = (rgb_t *)malloc(sizeof(*palette->adjusted_rgb15) * (numcolors * numgroups + 2)); if (palette->adjusted_color == NULL || palette->adjusted_rgb15 == NULL) goto error; @@ -280,14 +280,14 @@ palette_client *palette_client_alloc(palette_t *palette) palette_client *client; /* allocate memory for the client */ - client = malloc(sizeof(*client)); + client = (palette_client *)malloc(sizeof(*client)); if (client == NULL) goto error; memset(client, 0, sizeof(*client)); /* allocate dirty lists */ - client->live.dirty = malloc(dirty_dwords * sizeof(UINT32)); - client->previous.dirty = malloc(dirty_dwords * sizeof(UINT32)); + client->live.dirty = (UINT32 *)malloc(dirty_dwords * sizeof(UINT32)); + client->previous.dirty = (UINT32 *)malloc(dirty_dwords * sizeof(UINT32)); if (client->live.dirty == NULL || client->previous.dirty == NULL) goto error; diff --git a/src/lib/util/png.c b/src/lib/util/png.c index 2346419c2df..e6a1fd242fc 100644 --- a/src/lib/util/png.c +++ b/src/lib/util/png.c @@ -271,7 +271,7 @@ static png_error process_chunk(png_private *png, UINT8 *data, UINT32 type, UINT3 case PNG_CN_IDAT: /* allocate a new image data descriptor */ - *png->idata_next = malloc(sizeof(**png->idata_next)); + *png->idata_next = (image_data_chunk *)malloc(sizeof(**png->idata_next)); if (*png->idata_next == NULL) return PNGERR_OUT_OF_MEMORY; @@ -301,7 +301,7 @@ static png_error process_chunk(png_private *png, UINT8 *data, UINT32 type, UINT3 png_text *text, *pt, *ct; /* allocate a new text item */ - text = malloc(sizeof(*text)); + text = (png_text *)malloc(sizeof(*text)); if (text == NULL) return PNGERR_OUT_OF_MEMORY; @@ -668,7 +668,7 @@ png_error png_expand_buffer_8bit(png_info *pnginfo) return PNGERR_NONE; /* allocate a new buffer at 8-bit */ - outbuf = malloc(pnginfo->width * pnginfo->height); + outbuf = (UINT8 *)malloc(pnginfo->width * pnginfo->height); if (outbuf == NULL) return PNGERR_OUT_OF_MEMORY; @@ -713,13 +713,13 @@ png_error png_add_text(png_info *pnginfo, const char *keyword, const char *text) int keylen; /* allocate a new text element */ - newtext = malloc(sizeof(*newtext)); + newtext = (png_text *)malloc(sizeof(*newtext)); if (newtext == NULL) return PNGERR_OUT_OF_MEMORY; /* allocate a string long enough to hold both */ keylen = (int)strlen(keyword); - textdata = malloc(keylen + 1 + strlen(text) + 1); + textdata = (char *)malloc(keylen + 1 + strlen(text) + 1); if (textdata == NULL) { free(newtext); @@ -887,7 +887,7 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap rowbytes = pnginfo->width; /* allocate memory for the palette */ - pnginfo->palette = malloc(3 * 256); + pnginfo->palette = (UINT8 *)malloc(3 * 256); if (pnginfo->palette == NULL) return PNGERR_OUT_OF_MEMORY; @@ -902,7 +902,7 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap } /* allocate memory for the image */ - pnginfo->image = malloc(pnginfo->height * (rowbytes + 1)); + pnginfo->image = (UINT8 *)malloc(pnginfo->height * (rowbytes + 1)); if (pnginfo->image == NULL) { free(pnginfo->palette); @@ -944,7 +944,7 @@ static png_error convert_bitmap_to_image_rgb(png_info *pnginfo, const bitmap_t * rowbytes = pnginfo->width * (alpha ? 4 : 3); /* allocate memory for the image */ - pnginfo->image = malloc(pnginfo->height * (rowbytes + 1)); + pnginfo->image = (UINT8 *)malloc(pnginfo->height * (rowbytes + 1)); if (pnginfo->image == NULL) return PNGERR_OUT_OF_MEMORY; diff --git a/src/lib/util/pool.c b/src/lib/util/pool.c index 479c61cbd21..387c23e2a50 100644 --- a/src/lib/util/pool.c +++ b/src/lib/util/pool.c @@ -140,7 +140,7 @@ object_pool *pool_alloc(void (*fail)(const char *message)) object_pool *pool; /* allocate memory for the pool itself */ - pool = malloc(sizeof(*pool)); + pool = (object_pool *)malloc(sizeof(*pool)); if (pool == NULL) return NULL; memset(pool, 0, sizeof(*pool)); @@ -168,7 +168,7 @@ void pool_type_register(object_pool *pool, object_type type, const char *friendl if (newtype == NULL) { /* allocate a new entry */ - newtype = malloc(sizeof(*newtype)); + newtype = (objtype_entry *)malloc(sizeof(*newtype)); if (newtype == NULL) { report_failure(pool, "Error adding new type %s\n", friendly); @@ -286,7 +286,7 @@ void *pool_object_add_file_line(object_pool *pool, object_type _type, void *obje int entrynum; /* if we need a new block, allocate that now */ - block = malloc(sizeof(*block)); + block = (object_entry_block *)malloc(sizeof(*block)); if (block == NULL) return NULL; memset(block, 0, sizeof(*block)); @@ -403,7 +403,7 @@ object_pool_iterator *pool_iterate_begin(object_pool *pool, object_type type) object_pool_iterator *iter; /* allocate the iterator */ - iter = malloc(sizeof(*iter)); + iter = (object_pool_iterator *)malloc(sizeof(*iter)); if (iter == NULL) return NULL; memset(iter, 0, sizeof(*iter)); @@ -505,7 +505,7 @@ void *pool_realloc_file_line(object_pool *pool, void *ptr, size_t size, const ch char *pool_strdup_file_line(object_pool *pool, const char *str, const char *file, int line) { - char *ptr = pool_malloc_file_line(pool, strlen(str) + 1, file, line); + char *ptr = (char *)pool_malloc_file_line(pool, strlen(str) + 1, file, line); if (ptr != NULL) strcpy(ptr, str); return ptr; diff --git a/src/lib/util/unzip.c b/src/lib/util/unzip.c index 5e9ec06c325..e49fc4c4057 100644 --- a/src/lib/util/unzip.c +++ b/src/lib/util/unzip.c @@ -149,7 +149,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) } /* allocate memory for the zip_file structure */ - newzip = malloc(sizeof(*newzip)); + newzip = (zip_file *)malloc(sizeof(*newzip)); if (newzip == NULL) return ZIPERR_OUT_OF_MEMORY; memset(newzip, 0, sizeof(*newzip)); @@ -175,7 +175,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) } /* allocate memory for the central directory */ - newzip->cd = malloc(newzip->ecd.cd_size + 1); + newzip->cd = (UINT8 *)malloc(newzip->ecd.cd_size + 1); if (newzip->cd == NULL) { ziperr = ZIPERR_OUT_OF_MEMORY; @@ -191,7 +191,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) } /* make a copy of the filename for caching purposes */ - string = malloc(strlen(filename) + 1); + string = (char *)malloc(strlen(filename) + 1); if (string == NULL) { ziperr = ZIPERR_OUT_OF_MEMORY; @@ -427,7 +427,7 @@ static zip_error read_ecd(zip_file *zip) buflen = zip->length; /* allocate buffer */ - buffer = malloc(buflen + 1); + buffer = (UINT8 *)malloc(buflen + 1); if (buffer == NULL) return ZIPERR_OUT_OF_MEMORY; @@ -556,7 +556,7 @@ static zip_error decompress_data_type_8(zip_file *zip, UINT64 offset, void *buff /* reset the stream */ memset(&stream, 0, sizeof(stream)); - stream.next_out = buffer; + stream.next_out = (Bytef *)buffer; stream.avail_out = length; /* initialize the decompressor */ diff --git a/src/lib/util/xmlfile.c b/src/lib/util/xmlfile.c index 70adc563f8f..b400349a06d 100644 --- a/src/lib/util/xmlfile.c +++ b/src/lib/util/xmlfile.c @@ -75,7 +75,7 @@ static const char *copystring(const char *input) return NULL; /* make a lower-case copy if the allocation worked */ - newstr = malloc(strlen(input) + 1); + newstr = (char *)malloc(strlen(input) + 1); if (newstr != NULL) strcpy(newstr, input); @@ -99,7 +99,7 @@ static const char *copystring_lower(const char *input) return NULL; /* make a lower-case copy if the allocation worked */ - newstr = malloc(strlen(input) + 1); + newstr = (char *)malloc(strlen(input) + 1); if (newstr != NULL) { for (i = 0; input[i] != 0; i++) @@ -126,7 +126,7 @@ xml_data_node *xml_file_create(void) xml_data_node *rootnode; /* create a root node */ - rootnode = malloc(sizeof(*rootnode)); + rootnode = (xml_data_node *)malloc(sizeof(*rootnode)); if (rootnode == NULL) return NULL; memset(rootnode, 0, sizeof(*rootnode)); @@ -680,7 +680,7 @@ static void expat_data(void *data, const XML_Char *s, int len) oldlen = (int)strlen((*curnode)->value); /* realloc */ - newdata = realloc((void *)(*curnode)->value, oldlen + len + 1); + newdata = (char *)realloc((void *)(*curnode)->value, oldlen + len + 1); if (newdata == NULL) return; @@ -752,7 +752,7 @@ static xml_data_node *add_child(xml_data_node *parent, const char *name, const c xml_data_node *node; /* new element: create a new node */ - node = malloc(sizeof(*node)); + node = (xml_data_node *)malloc(sizeof(*node)); if (node == NULL) return NULL; @@ -793,7 +793,7 @@ static xml_attribute_node *add_attribute(xml_data_node *node, const char *name, xml_attribute_node *anode, **panode; /* allocate a new attribute node */ - anode = malloc(sizeof(*anode)); + anode = (xml_attribute_node *)malloc(sizeof(*anode)); if (anode == NULL) return NULL; |