From 80171dc3acb725f61e1e01451727ece8e6dc9457 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Thu, 30 Dec 2004 03:57:13 +0000 Subject: [PATCH] fix all bare malloc() realloc() etc calls to have a proper cast in front --- src/flac/main.c | 2 +- src/libFLAC/metadata_object.c | 6 +++--- src/libOggFLAC/ogg_helper.c | 4 ++-- src/plugin_common/charset.c | 2 +- src/plugin_common/tags.c | 2 +- src/plugin_winamp2/infobox.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/flac/main.c b/src/flac/main.c index 1ddea28..86cf715 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -631,7 +631,7 @@ int parse_options(int argc, char *argv[]) if(option_values.num_files > 0) { unsigned i = 0; - if(0 == (option_values.filenames = malloc(sizeof(char *) * option_values.num_files))) + if(0 == (option_values.filenames = (char**)malloc(sizeof(char*) * option_values.num_files))) die("out of memory allocating space for file names list"); while(share__optind < argc) option_values.filenames[i++] = local_strdup(argv[share__optind++]); diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c index 8907bdd..d1c0792 100644 --- a/src/libFLAC/metadata_object.c +++ b/src/libFLAC/metadata_object.c @@ -1131,7 +1131,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pa const size_t nn = strlen(field_name); const size_t nv = strlen(field_value); entry->length = nn + 1 /*=*/ + nv; - if(0 == (entry->entry = malloc(entry->length+1))) + if(0 == (entry->entry = (FLAC__byte*)malloc(entry->length+1))) return false; memcpy(entry->entry, field_name, nn); entry->entry[nn] = '='; @@ -1158,9 +1158,9 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair FLAC__ASSERT(0 != eq); if(0 == eq) return false; /* double protection */ - if(0 == (*field_name = malloc(nn+1))) + if(0 == (*field_name = (char*)malloc(nn+1))) return false; - if(0 == (*field_value = malloc(nv+1))) { + if(0 == (*field_value = (char*)malloc(nv+1))) { free(*field_name); return false; } diff --git a/src/libOggFLAC/ogg_helper.c b/src/libOggFLAC/ogg_helper.c index 5ee534d..169ee3a 100644 --- a/src/libOggFLAC/ogg_helper.c +++ b/src/libOggFLAC/ogg_helper.c @@ -102,7 +102,7 @@ FLAC__bool simple_ogg_page__get_at(OggFLAC__SeekableStreamEncoder *encoder, FLAC } /* allocate space for the page header */ - if(0 == (page->header = malloc(OGG_MAX_HEADER_LEN))) { + if(0 == (page->header = (unsigned char *)malloc(OGG_MAX_HEADER_LEN))) { encoder->protected_->state = OggFLAC__SEEKABLE_STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; return false; } @@ -144,7 +144,7 @@ FLAC__bool simple_ogg_page__get_at(OggFLAC__SeekableStreamEncoder *encoder, FLAC } /* allocate space for the page body */ - if(0 == (page->body = malloc(page->body_len))) { + if(0 == (page->body = (unsigned char *)malloc(page->body_len))) { encoder->protected_->state = OggFLAC__SEEKABLE_STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; return false; } diff --git a/src/plugin_common/charset.c b/src/plugin_common/charset.c index d5c159e..ce3e8b8 100644 --- a/src/plugin_common/charset.c +++ b/src/plugin_common/charset.c @@ -83,7 +83,7 @@ char* FLAC_plugin__charset_convert_string (const char *string, char *from, char /* Due to a GLIBC bug, round outbuf_size up to a multiple of 4 */ /* + 1 for nul in case len == 1 */ outsize = ((length + 3) & ~3) + 1; - out = malloc(outsize); + out = (char*)malloc(outsize); outleft = outsize - 1; outptr = out; diff --git a/src/plugin_common/tags.c b/src/plugin_common/tags.c index 1de2a8a..c69d1b0 100644 --- a/src/plugin_common/tags.c +++ b/src/plugin_common/tags.c @@ -265,7 +265,7 @@ FLAC__bool FLAC_plugin__tags_add_tag_utf8(FLAC__StreamMetadata *tags, const char const size_t value_len = strlen(value); const size_t separator_len = strlen(separator); FLAC__byte *new_entry; - if(0 == (new_entry = realloc(entry->entry, entry->length + value_len + separator_len + 1))) + if(0 == (new_entry = (FLAC__byte*)realloc(entry->entry, entry->length + value_len + separator_len + 1))) return false; memcpy(new_entry+entry->length, separator, separator_len); entry->length += separator_len; diff --git a/src/plugin_winamp2/infobox.c b/src/plugin_winamp2/infobox.c index 8890089..dddcff5 100644 --- a/src/plugin_winamp2/infobox.c +++ b/src/plugin_winamp2/infobox.c @@ -183,7 +183,7 @@ static wchar_t *AnsiToWide(const char *src) len = strlen(src) + 1; /* copy */ - dest = malloc(len*sizeof(wchar_t)); + dest = (wchar_t*)malloc(len*sizeof(wchar_t)); if (dest) mbstowcs(dest, src, len); return dest; } -- 2.7.4