summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-04-27 09:18:17 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-04-27 09:18:17 +0000
commit9eb86548bbb847ca2fc01f04fc3a4caa3568aefe (patch)
tree7bc8d0a67746251f1ec2dc38d52a1e8da5c381be /src/tools
parent5d4816b66528f07a78ce8470413c524cbb57c799 (diff)
Added missing casts and made other tweaks. The entire project
can now be optionally compiled with the C++ compiler (mingw g++ only for the moment; MSVC still has issues).
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/chdman.c22
-rw-r--r--src/tools/jedutil.c6
-rw-r--r--src/tools/ldresample.c4
-rw-r--r--src/tools/ldverify.c20
-rw-r--r--src/tools/regrep.c26
-rw-r--r--src/tools/romcmp.c4
-rw-r--r--src/tools/src2html.c20
7 files changed, 51 insertions, 51 deletions
diff --git a/src/tools/chdman.c b/src/tools/chdman.c
index 8e0fb2175c3..0f2a8e8957c 100644
--- a/src/tools/chdman.c
+++ b/src/tools/chdman.c
@@ -519,7 +519,7 @@ static int do_createcd(int argc, char *argv[], int param)
outputfile = argv[3];
/* allocate a cache */
- cache = malloc(hunksize);
+ cache = (UINT8 *)malloc(hunksize);
if (cache == NULL)
{
fprintf(stderr, "Out of memory allocating temporary buffer\n");
@@ -933,7 +933,7 @@ static int do_createav(int argc, char *argv[], int param)
/* allocate space for the frame data */
if (height == 524/2 || height == 624/2)
{
- ldframedata = malloc(numframes * VBI_PACKED_BYTES);
+ ldframedata = (UINT8 *)malloc(numframes * VBI_PACKED_BYTES);
if (ldframedata == NULL)
{
fprintf(stderr, "Out of memory allocating frame metadata\n");
@@ -961,7 +961,7 @@ static int do_createav(int argc, char *argv[], int param)
avconfig.channels = channels;
for (chnum = 0; chnum < channels; chnum++)
{
- avconfig.audio[chnum] = malloc(max_samples_per_frame * 2);
+ avconfig.audio[chnum] = (INT16 *)malloc(max_samples_per_frame * 2);
if (avconfig.audio[chnum] == NULL)
{
fprintf(stderr, "Out of memory allocating temporary audio buffer\n");
@@ -1143,7 +1143,7 @@ static int do_createblankhd(int argc, char *argv[], int param)
}
/* alloc and zero buffer*/
- cache = malloc(hunksize);
+ cache = (UINT8 *)malloc(hunksize);
if (cache == NULL)
{
fprintf(stderr, "Error allocating memory buffer\n");
@@ -1608,7 +1608,7 @@ static int do_extractav(int argc, char *argv[], int param)
avconfig.actsamples = &numsamples;
for (chnum = 0; chnum < channels; chnum++)
{
- avconfig.audio[chnum] = malloc(avconfig.maxsamples * 2);
+ avconfig.audio[chnum] = (INT16 *)malloc(avconfig.maxsamples * 2);
if (avconfig.audio[chnum] == NULL)
{
fprintf(stderr, "Out of memory allocating temporary audio buffer\n");
@@ -1954,7 +1954,7 @@ static int do_fixavdata(int argc, char *argv[], int param)
avconfig.video = &fakebitmap;
/* allocate memory for VBI data */
- vbidata = malloc(header.totalhunks * VBI_PACKED_BYTES);
+ vbidata = (UINT8 *)malloc(header.totalhunks * VBI_PACKED_BYTES);
if (vbidata == NULL)
{
fprintf(stderr, "Out of memory allocating VBI data\n");
@@ -2762,7 +2762,7 @@ static int do_addmeta(int argc, char *argv[], int param)
/* if it's text, strip any trailing Ctrl-Z and CR/LF and add a trailing NULL */
if (param)
{
- metadata = realloc(metadata, metalength + 1);
+ metadata = (UINT8 *)realloc(metadata, metalength + 1);
if (metadata == NULL)
{
fprintf(stderr, "Out of memory preparing metadata\n");
@@ -2838,7 +2838,7 @@ static chd_error chdman_compress_file(chd_file *chd, const char *rawfile, UINT32
/* get the header */
header = chd_get_header(chd);
- cache = malloc(header->hunkbytes);
+ cache = (UINT8 *)malloc(header->hunkbytes);
if (cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
@@ -2909,7 +2909,7 @@ static chd_error chdman_compress_chd(chd_file *chd, chd_file *source, UINT32 tot
/* get the header */
header = chd_get_header(chd);
- cache = malloc(header->hunkbytes);
+ cache = (UINT8 *)malloc(header->hunkbytes);
if (cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
@@ -2918,7 +2918,7 @@ static chd_error chdman_compress_chd(chd_file *chd, chd_file *source, UINT32 tot
/* get the source CHD header */
source_header = chd_get_header(source);
- source_cache = malloc(source_header->hunkbytes);
+ source_cache = (UINT8 *)malloc(source_header->hunkbytes);
if (source_cache == NULL)
{
err = CHDERR_OUT_OF_MEMORY;
@@ -3166,7 +3166,7 @@ int CLIB_DECL main(int argc, char **argv)
{ "-addmetatext", do_addmeta, TRUE },
{ "-addmetabin", do_addmeta, FALSE },
};
- extern char build_version[];
+ extern const char build_version[];
int i;
/* print the header */
diff --git a/src/tools/jedutil.c b/src/tools/jedutil.c
index d48e28a0007..409dc55114c 100644
--- a/src/tools/jedutil.c
+++ b/src/tools/jedutil.c
@@ -99,7 +99,7 @@ static int read_source_file(const char *srcfile)
fseek(file, 0, SEEK_END);
srcbuflen = ftell(file);
fseek(file, 0, SEEK_SET);
- srcbuf = malloc(srcbuflen);
+ srcbuf = (UINT8 *)malloc(srcbuflen);
if (!srcbuf)
{
fprintf(stderr, "Unable to allocate %d bytes for the source!\n", (int)srcbuflen);
@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
/* generate the output */
dstbuflen = jedbin_output(&jed, NULL, 0);
- dstbuf = malloc(dstbuflen);
+ dstbuf = (UINT8 *)malloc(dstbuflen);
if (!dstbuf)
{
fprintf(stderr, "Unable to allocate %d bytes for the target buffer!\n", (int)dstbuflen);
@@ -270,7 +270,7 @@ int main(int argc, char *argv[])
/* generate the output */
dstbuflen = jed_output(&jed, NULL, 0);
- dstbuf = malloc(dstbuflen);
+ dstbuf = (UINT8 *)malloc(dstbuflen);
if (!dstbuf)
{
fprintf(stderr, "Unable to allocate %d bytes for the target buffer!\n", (int)dstbuflen);
diff --git a/src/tools/ldresample.c b/src/tools/ldresample.c
index 6ec450ca651..c995c820363 100644
--- a/src/tools/ldresample.c
+++ b/src/tools/ldresample.c
@@ -129,8 +129,8 @@ static int chd_allocate_buffers(movie_info *info)
}
/* allocate sound buffers */
- info->lsound = malloc(info->samplerate * sizeof(*info->lsound));
- info->rsound = malloc(info->samplerate * sizeof(*info->rsound));
+ info->lsound = (INT16 *)malloc(info->samplerate * sizeof(*info->lsound));
+ info->rsound = (INT16 *)malloc(info->samplerate * sizeof(*info->rsound));
if (info->lsound == NULL || info->rsound == NULL)
{
fprintf(stderr, "Out of memory allocating sound buffers of %d bytes\n", (INT32)(info->samplerate * sizeof(*info->rsound)));
diff --git a/src/tools/ldverify.c b/src/tools/ldverify.c
index 1e52ab53128..187bea0cefa 100644
--- a/src/tools/ldverify.c
+++ b/src/tools/ldverify.c
@@ -123,19 +123,19 @@ static void *open_avi(const char *filename, movie_info *info)
static int read_avi(void *file, int frame, bitmap_t *bitmap, INT16 *lsound, INT16 *rsound, int *samples)
{
- const avi_movie_info *aviinfo = avi_get_movie_info(file);
+ const avi_movie_info *aviinfo = avi_get_movie_info((avi_file *)file);
UINT32 firstsample = ((UINT64)aviinfo->audio_samplerate * (UINT64)frame * (UINT64)aviinfo->video_sampletime + aviinfo->video_timescale - 1) / (UINT64)aviinfo->video_timescale;
UINT32 lastsample = ((UINT64)aviinfo->audio_samplerate * (UINT64)(frame + 1) * (UINT64)aviinfo->video_sampletime + aviinfo->video_timescale - 1) / (UINT64)aviinfo->video_timescale;
avi_error avierr;
/* read the frame */
- avierr = avi_read_video_frame_yuy16(file, frame, bitmap);
+ avierr = avi_read_video_frame_yuy16((avi_file *)file, frame, bitmap);
if (avierr != AVIERR_NONE)
return FALSE;
/* read the samples */
- avierr = avi_read_sound_samples(file, 0, firstsample, lastsample - firstsample, lsound);
- avierr = avi_read_sound_samples(file, 1, firstsample, lastsample - firstsample, rsound);
+ avierr = avi_read_sound_samples((avi_file *)file, 0, firstsample, lastsample - firstsample, lsound);
+ avierr = avi_read_sound_samples((avi_file *)file, 1, firstsample, lastsample - firstsample, rsound);
if (avierr != AVIERR_NONE)
return FALSE;
*samples = lastsample - firstsample;
@@ -149,7 +149,7 @@ static int read_avi(void *file, int frame, bitmap_t *bitmap, INT16 *lsound, INT1
static void close_avi(void *file)
{
- avi_close(file);
+ avi_close((avi_file *)file);
}
@@ -247,10 +247,10 @@ static int read_chd(void *file, int frame, bitmap_t *bitmap, INT16 *lsound, INT1
avconfig.audio[1] = &rsound[*samples];
/* configure the decompressor for this frame */
- chd_codec_config(file, AV_CODEC_DECOMPRESS_CONFIG, &avconfig);
+ chd_codec_config((chd_file *)file, AV_CODEC_DECOMPRESS_CONFIG, &avconfig);
/* read the frame */
- chderr = chd_read(file, frame * interlace_factor + fieldnum, NULL);
+ chderr = chd_read((chd_file *)file, frame * interlace_factor + fieldnum, NULL);
if (chderr != CHDERR_NONE)
return FALSE;
@@ -267,7 +267,7 @@ static int read_chd(void *file, int frame, bitmap_t *bitmap, INT16 *lsound, INT1
static void close_chd(void *file)
{
- chd_close(file);
+ chd_close((chd_file *)file);
}
@@ -723,8 +723,8 @@ int main(int argc, char *argv[])
}
/* allocate sound buffers */
- lsound = malloc(info.samplerate * sizeof(*lsound));
- rsound = malloc(info.samplerate * sizeof(*rsound));
+ lsound = (INT16 *)malloc(info.samplerate * sizeof(*lsound));
+ rsound = (INT16 *)malloc(info.samplerate * sizeof(*rsound));
if (lsound == NULL || rsound == NULL)
{
isavi ? close_avi(file) : close_chd(file);
diff --git a/src/tools/regrep.c b/src/tools/regrep.c
index 255b3b7b701..1f0b456854a 100644
--- a/src/tools/regrep.c
+++ b/src/tools/regrep.c
@@ -151,8 +151,8 @@ static int CLIB_DECL compare_file(const void *file0ptr, const void *file1ptr);
static summary_file *sort_file_list(void);
/* HTML helpers */
-static core_file *create_file_and_output_header(const astring *filename, const astring *template, const astring *title);
-static void output_footer_and_close_file(core_file *file, const astring *template, const astring *title);
+static core_file *create_file_and_output_header(const astring *filename, const astring *templatefile, const astring *title);
+static void output_footer_and_close_file(core_file *file, const astring *templatefile, const astring *title);
/* report generators */
static void output_report(const astring *dirname, const astring *tempheader, const astring *tempfooter, summary_file *filelist);
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
/* read the template file into an astring */
if (core_fload(astring_c(tempfilename), &buffer, &bufsize) == FILERR_NONE)
{
- tempheader = astring_dupch(buffer, bufsize);
+ tempheader = astring_dupch((const char *)buffer, bufsize);
free(buffer);
}
@@ -299,7 +299,7 @@ static summary_file *get_file(const char *filename)
return file;
/* didn't find one -- allocate */
- file = malloc(sizeof(*file));
+ file = (summary_file *)malloc(sizeof(*file));
if (file == NULL)
return NULL;
memset(file, 0, sizeof(*file));
@@ -376,7 +376,7 @@ static int read_summary_log(const char *filename, int index)
char *dirname = trim_string(linestart + 4);
/* allocate a copy of the string */
- lists[index].dir = malloc(strlen(dirname) + 1);
+ lists[index].dir = (char *)malloc(strlen(dirname) + 1);
if (lists[index].dir == NULL)
goto error;
strcpy(lists[index].dir, dirname);
@@ -413,7 +413,7 @@ static int read_summary_log(const char *filename, int index)
if (curfile->textsize[index] + (curptr - linestart) + 1 >= curfile->textalloc[index])
{
curfile->textalloc[index] = curfile->textsize[index] + (curptr - linestart) + 256;
- curfile->text[index] = realloc(curfile->text[index], curfile->textalloc[index]);
+ curfile->text[index] = (char *)realloc(curfile->text[index], curfile->textalloc[index]);
if (curfile->text[index] == NULL)
{
fprintf(stderr, "Unable to allocate memory for text\n");
@@ -542,7 +542,7 @@ static summary_file *sort_file_list(void)
numfiles++;
/* allocate an array of files */
- filearray = malloc(numfiles * sizeof(*filearray));
+ filearray = (summary_file **)malloc(numfiles * sizeof(*filearray));
if (filearray == NULL)
{
fprintf(stderr, "Out of memory!\n");
@@ -584,7 +584,7 @@ static summary_file *sort_file_list(void)
HTML file with a standard header
-------------------------------------------------*/
-static core_file *create_file_and_output_header(const astring *filename, const astring *template, const astring *title)
+static core_file *create_file_and_output_header(const astring *filename, const astring *templatefile, const astring *title)
{
astring *modified;
core_file *file;
@@ -594,7 +594,7 @@ static core_file *create_file_and_output_header(const astring *filename, const a
return NULL;
/* print a header */
- modified = astring_dup(template);
+ modified = astring_dup(templatefile);
astring_replacec(modified, 0, "<!--TITLE-->", astring_c(title));
core_fwrite(file, astring_c(modified), astring_len(modified));
@@ -609,11 +609,11 @@ static core_file *create_file_and_output_header(const astring *filename, const a
standard footer to an HTML file and close it
-------------------------------------------------*/
-static void output_footer_and_close_file(core_file *file, const astring *template, const astring *title)
+static void output_footer_and_close_file(core_file *file, const astring *templatefile, const astring *title)
{
astring *modified;
- modified = astring_dup(template);
+ modified = astring_dup(templatefile);
astring_replacec(modified, 0, "<!--TITLE-->", astring_c(title));
core_fwrite(file, astring_c(modified), astring_len(modified));
astring_free(modified);
@@ -904,7 +904,7 @@ static int generate_png_diff(const summary_file *curfile, const astring *destdir
/* load the source image */
pngerr = png_read_bitmap(file, &bitmaps[bitmapcount++]);
core_fclose(file);
- if (pngerr != FILERR_NONE)
+ if (pngerr != PNGERR_NONE)
goto error;
}
@@ -976,7 +976,7 @@ static int generate_png_diff(const summary_file *curfile, const astring *destdir
goto error;
pngerr = png_write_bitmap(file, NULL, finalbitmap, 0, NULL);
core_fclose(file);
- if (pngerr != FILERR_NONE)
+ if (pngerr != PNGERR_NONE)
goto error;
/* if we get here, we are error free */
diff --git a/src/tools/romcmp.c b/src/tools/romcmp.c
index 5cc39855f76..5271e5d2675 100644
--- a/src/tools/romcmp.c
+++ b/src/tools/romcmp.c
@@ -405,7 +405,7 @@ static void readfile(const char *path,fileinfo *file)
else fullname[0] = 0;
strcat(fullname,file->name);
- if ((file->buf = malloc(file->size)) == 0)
+ if ((file->buf = (unsigned char *)malloc(file->size)) == 0)
{
printf("%s: out of memory!\n",file->name);
return;
@@ -522,7 +522,7 @@ static int load_files(int i, int *found, const char *path)
else
strcpy(file->name,zipent->filename);
file->size = zipent->uncompressed_length;
- if ((file->buf = malloc(file->size)) == 0)
+ if ((file->buf = (unsigned char *)malloc(file->size)) == 0)
printf("%s: out of memory!\n",file->name);
else
{
diff --git a/src/tools/src2html.c b/src/tools/src2html.c
index 0b5322d516b..6f5719f74b6 100644
--- a/src/tools/src2html.c
+++ b/src/tools/src2html.c
@@ -181,8 +181,8 @@ static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, co
static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file, const astring *tempheader, const astring *tempfooter);
/* HTML helpers */
-static core_file *create_file_and_output_header(const astring *filename, const astring *template, const astring *path);
-static void output_footer_and_close_file(core_file *file, const astring *template, const astring *path);
+static core_file *create_file_and_output_header(const astring *filename, const astring *templatefile, const astring *path);
+static void output_footer_and_close_file(core_file *file, const astring *templatefile, const astring *path);
/* path helpers */
static const astring *normalized_subpath(const astring *path, int start);
@@ -216,7 +216,7 @@ int main(int argc, char *argv[])
/* include path? */
if (arg[0] == '-' && arg[1] == 'I')
{
- *incpathhead = malloc(sizeof(**incpathhead));
+ *incpathhead = (include_path *)malloc(sizeof(**incpathhead));
if (*incpathhead != NULL)
{
(*incpathhead)->next = NULL;
@@ -252,7 +252,7 @@ int main(int argc, char *argv[])
/* read the template file into an astring */
if (core_fload(astring_c(tempfilename), &buffer, &bufsize) == FILERR_NONE)
{
- tempheader = astring_dupch(buffer, bufsize);
+ tempheader = astring_dupch((const char *)buffer, bufsize);
free(buffer);
}
@@ -353,7 +353,7 @@ static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, co
while ((entry = osd_readdir(dir)) != NULL)
if (entry->type == entry_type && entry->name[0] != '.')
{
- list_entry *lentry = malloc(sizeof(*lentry));
+ list_entry *lentry = (list_entry *)malloc(sizeof(*lentry));
lentry->name = astring_dupc(entry->name);
lentry->next = list;
list = lentry;
@@ -368,7 +368,7 @@ static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, co
continue;
/* allocate memory for sorting */
- listarray = malloc(sizeof(list_entry *) * found);
+ listarray = (list_entry **)malloc(sizeof(list_entry *) * found);
found = 0;
for (curlist = list; curlist != NULL; curlist = curlist->next)
listarray[found++] = curlist;
@@ -734,7 +734,7 @@ static int output_file(file_type type, int srcrootlen, int dstrootlen, const ast
HTML file with a standard header
-------------------------------------------------*/
-static core_file *create_file_and_output_header(const astring *filename, const astring *template, const astring *path)
+static core_file *create_file_and_output_header(const astring *filename, const astring *templatefile, const astring *path)
{
astring *modified;
core_file *file;
@@ -744,7 +744,7 @@ static core_file *create_file_and_output_header(const astring *filename, const a
return NULL;
/* print a header */
- modified = astring_dup(template);
+ modified = astring_dup(templatefile);
astring_replacec(modified, 0, "<!--PATH-->", astring_c(path));
core_fwrite(file, astring_c(modified), astring_len(modified));
@@ -759,11 +759,11 @@ static core_file *create_file_and_output_header(const astring *filename, const a
standard footer to an HTML file and close it
-------------------------------------------------*/
-static void output_footer_and_close_file(core_file *file, const astring *template, const astring *path)
+static void output_footer_and_close_file(core_file *file, const astring *templatefile, const astring *path)
{
astring *modified;
- modified = astring_dup(template);
+ modified = astring_dup(templatefile);
astring_replacec(modified, 0, "<!--PATH-->", astring_c(path));
core_fwrite(file, astring_c(modified), astring_len(modified));
astring_free(modified);