Commit 5e3fcb26 authored by Josh Coalson's avatar Josh Coalson
Browse files

more strict typecasts

parent 7424d2ff
......@@ -278,9 +278,9 @@ FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_s
FLAC__ASSERT(object->capacity_by_order > 0 || (0 == object->parameters && 0 == object->raw_bits));
if(object->capacity_by_order < max_partition_order) {
if(0 == (object->parameters = realloc(object->parameters, sizeof(unsigned)*(1 << max_partition_order))))
if(0 == (object->parameters = (unsigned*)realloc(object->parameters, sizeof(unsigned)*(1 << max_partition_order))))
return false;
if(0 == (object->raw_bits = realloc(object->raw_bits, sizeof(unsigned)*(1 << max_partition_order))))
if(0 == (object->raw_bits = (unsigned*)realloc(object->raw_bits, sizeof(unsigned)*(1 << max_partition_order))))
return false;
object->capacity_by_order = max_partition_order;
}
......
......@@ -229,10 +229,10 @@ FLAC__MD5Accumulate(struct MD5Context *ctx, const FLAC__int32 * const signal[],
const unsigned bytes_needed = channels * samples * bytes_per_sample;
if(ctx->capacity < bytes_needed) {
FLAC__byte *tmp = realloc(ctx->internal_buf, bytes_needed);
FLAC__byte *tmp = (FLAC__byte*)realloc(ctx->internal_buf, bytes_needed);
if(0 == tmp) {
free(ctx->internal_buf);
if(0 == (ctx->internal_buf = malloc(bytes_needed)))
if(0 == (ctx->internal_buf = (FLAC__byte*)malloc(bytes_needed)))
return false;
}
ctx->internal_buf = tmp;
......
......@@ -46,7 +46,7 @@ FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(FLAC__int32) * elements, (void*)&pa);
pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(FLAC__int32) * elements, (void**)&pa);
if(0 == pu) {
return false;
}
......@@ -68,7 +68,7 @@ FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(FLAC__uint32) * elements, (void*)&pa);
pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(FLAC__uint32) * elements, (void**)&pa);
if(0 == pu) {
return false;
}
......@@ -90,7 +90,7 @@ FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(FLAC__uint64) * elements, (void*)&pa);
pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(FLAC__uint64) * elements, (void**)&pa);
if(0 == pu) {
return false;
}
......@@ -112,7 +112,7 @@ FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
pu = (unsigned*)FLAC__memory_alloc_aligned(sizeof(unsigned) * elements, (void*)&pa);
pu = (unsigned*)FLAC__memory_alloc_aligned(sizeof(unsigned) * elements, (void**)&pa);
if(0 == pu) {
return false;
}
......@@ -134,7 +134,7 @@ FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real *
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(FLAC__real) * elements, (void*)&pa);
pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(FLAC__real) * elements, (void**)&pa);
if(0 == pu) {
return false;
}
......
......@@ -242,7 +242,7 @@ FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[] = {
FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new()
{
FLAC__Metadata_SimpleIterator *iterator = calloc(1, sizeof(FLAC__Metadata_SimpleIterator));
FLAC__Metadata_SimpleIterator *iterator = (FLAC__Metadata_SimpleIterator*)calloc(1, sizeof(FLAC__Metadata_SimpleIterator));
if(0 != iterator) {
iterator->file = 0;
......@@ -885,7 +885,7 @@ static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLA
FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new()
{
FLAC__Metadata_Chain *chain = calloc(1, sizeof(FLAC__Metadata_Chain));
FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)calloc(1, sizeof(FLAC__Metadata_Chain));
if(0 != chain) {
chain->filename = 0;
......@@ -1099,7 +1099,7 @@ FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain)
FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new()
{
FLAC__Metadata_Iterator *iterator = calloc(1, sizeof(FLAC__Metadata_Iterator));
FLAC__Metadata_Iterator *iterator = (FLAC__Metadata_Iterator*)calloc(1, sizeof(FLAC__Metadata_Iterator));
/* calloc() implies:
iterator->current = 0;
......@@ -1429,7 +1429,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_(FILE *
block->data = 0;
}
else {
if(0 == (block->data = malloc(block_length)))
if(0 == (block->data = (FLAC__byte*)malloc(block_length)))
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
if(fread(block->data, 1, block_length, file) != block_length)
......@@ -1451,7 +1451,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_(FILE *fi
if(block->num_points == 0)
block->points = 0;
else if(0 == (block->points = malloc(block->num_points * sizeof(FLAC__StreamMetadata_SeekPoint))))
else if(0 == (block->points = (FLAC__StreamMetadata_SeekPoint*)malloc(block->num_points * sizeof(FLAC__StreamMetadata_SeekPoint))))
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
for(i = 0; i < block->num_points; i++) {
......@@ -1485,7 +1485,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entr
entry->entry = 0;
}
else {
if(0 == (entry->entry = malloc(entry->length)))
if(0 == (entry->entry = (FLAC__byte*)malloc(entry->length)))
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
if(fread(entry->entry, 1, entry->length, file) != entry->length)
......@@ -1515,7 +1515,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_(FIL
if(block->num_comments == 0) {
block->comments = 0;
}
else if(0 == (block->comments = calloc(sizeof(FLAC__StreamMetadata_VorbisComment_Entry), block->num_comments)))
else if(0 == (block->comments = (FLAC__StreamMetadata_VorbisComment_Entry*)calloc(sizeof(FLAC__StreamMetadata_VorbisComment_Entry), block->num_comments)))
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
for(i = 0; i < block->num_comments; i++) {
......@@ -2132,7 +2132,7 @@ FLAC__bool open_tempfile_(const char *filename, const char *tempfile_path_prefix
{
static const char *tempfile_suffix = ".metadata_edit";
if(0 == tempfile_path_prefix) {
if(0 == (*tempfilename = malloc(strlen(filename) + strlen(tempfile_suffix) + 1))) {
if(0 == (*tempfilename = (char*)malloc(strlen(filename) + strlen(tempfile_suffix) + 1))) {
*status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
return false;
}
......@@ -2146,7 +2146,7 @@ FLAC__bool open_tempfile_(const char *filename, const char *tempfile_path_prefix
else
p++;
if(0 == (*tempfilename = malloc(strlen(tempfile_path_prefix) + 1 + strlen(p) + strlen(tempfile_suffix) + 1))) {
if(0 == (*tempfilename = (char*)malloc(strlen(tempfile_path_prefix) + 1 + strlen(p) + strlen(tempfile_suffix) + 1))) {
*status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
return false;
}
......
......@@ -35,7 +35,7 @@ static FLAC__bool copy_bytes_(FLAC__byte **to, const FLAC__byte *from, unsigned
{
if(bytes > 0 && 0 != from) {
FLAC__byte *x;
if(0 == (x = malloc(bytes)))
if(0 == (x = (FLAC__byte*)malloc(bytes)))
return false;
memcpy(x, from, bytes);
*to = x;
......@@ -58,7 +58,7 @@ static FLAC__bool copy_vcentry_(FLAC__StreamMetadata_VorbisComment_Entry *to, co
else {
FLAC__byte *x;
FLAC__ASSERT(from->length > 0);
if(0 == (x = malloc(from->length)))
if(0 == (x = (FLAC__byte*)malloc(from->length)))
return false;
memcpy(x, from->entry, from->length);
to->entry = x;
......@@ -80,7 +80,7 @@ static FLAC__StreamMetadata_SeekPoint *seekpoint_array_new_(unsigned num_points)
FLAC__ASSERT(num_points > 0);
object_array = malloc(num_points * sizeof(FLAC__StreamMetadata_SeekPoint));
object_array = (FLAC__StreamMetadata_SeekPoint*)malloc(num_points * sizeof(FLAC__StreamMetadata_SeekPoint));
if(0 != object_array) {
unsigned i;
......@@ -113,7 +113,7 @@ static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_new_(
{
FLAC__ASSERT(num_comments > 0);
return calloc(num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry));
return (FLAC__StreamMetadata_VorbisComment_Entry*)calloc(num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry));
}
static void vorbiscomment_entry_array_delete_(FLAC__StreamMetadata_VorbisComment_Entry *object_array, unsigned num_comments)
......@@ -197,7 +197,7 @@ static FLAC__bool vorbiscomment_set_entry_(FLAC__StreamMetadata *object, FLAC__S
FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type)
{
FLAC__StreamMetadata *object = calloc(1, sizeof(FLAC__StreamMetadata));
FLAC__StreamMetadata *object = (FLAC__StreamMetadata*)calloc(1, sizeof(FLAC__StreamMetadata));
if(0 != object) {
object->is_last = false;
object->type = type;
......@@ -503,7 +503,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMe
free(object->data.seek_table.points);
object->data.seek_table.points = 0;
}
else if(0 == (object->data.seek_table.points = realloc(object->data.seek_table.points, new_size)))
else if(0 == (object->data.seek_table.points = (FLAC__StreamMetadata_SeekPoint*)realloc(object->data.seek_table.points, new_size)))
return false;
/* if growing, set new elements to placeholders */
......@@ -703,7 +703,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__St
free(object->data.vorbis_comment.comments);
object->data.vorbis_comment.comments = 0;
}
else if(0 == (object->data.vorbis_comment.comments = realloc(object->data.vorbis_comment.comments, new_size)))
else if(0 == (object->data.vorbis_comment.comments = (FLAC__StreamMetadata_VorbisComment_Entry*)realloc(object->data.vorbis_comment.comments, new_size)))
return false;
/* if growing, zero all the length/pointers of new elements */
......@@ -767,13 +767,13 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__Str
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, unsigned field_name_length)
{
const FLAC__byte *eq = memchr(entry->entry, '=', entry->length);
const FLAC__byte *eq = (FLAC__byte*)memchr(entry->entry, '=', entry->length);
#if defined _MSC_VER || defined __MINGW32__
#define FLAC__STRNCASECMP strnicmp
#else
#define FLAC__STRNCASECMP strncasecmp
#endif
return (0 != eq && (unsigned)(eq-entry->entry) == field_name_length && 0 == FLAC__STRNCASECMP(field_name, entry->entry, field_name_length));
return (0 != eq && (unsigned)(eq-entry->entry) == field_name_length && 0 == FLAC__STRNCASECMP(field_name, (const char *)entry->entry, field_name_length));
#undef FLAC__STRNCASECMP
}
......
......@@ -446,7 +446,7 @@ FLAC_API FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_get_stat
return decoder->protected_->state;
}
FLAC_API FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_get_stream_decoder_state(const FLAC__SeekableStreamDecoder *decoder)
FLAC_API FLAC__StreamDecoderState FLAC__seekable_stream_decoder_get_stream_decoder_state(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
......
......@@ -178,7 +178,7 @@ FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new()
}
decoder->private_->metadata_filter_ids_capacity = 16;
if(0 == (decoder->private_->metadata_filter_ids = malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) * decoder->private_->metadata_filter_ids_capacity))) {
if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*)malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) * decoder->private_->metadata_filter_ids_capacity))) {
FLAC__bitbuffer_delete(decoder->private_->input);
free(decoder->private_);
free(decoder->protected_);
......@@ -407,7 +407,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__
FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids);
if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) {
if(0 == (decoder->private_->metadata_filter_ids = realloc(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity * 2)))
if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*)realloc(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity * 2)))
return decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
decoder->private_->metadata_filter_ids_capacity *= 2;
}
......@@ -461,7 +461,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__S
FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids);
if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) {
if(0 == (decoder->private_->metadata_filter_ids = realloc(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity * 2)))
if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*)realloc(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity * 2)))
return decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
decoder->private_->metadata_filter_ids_capacity *= 2;
}
......@@ -826,7 +826,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
return false; /* the read_callback_ sets the state for us */
if(type == FLAC__METADATA_TYPE_STREAMINFO) {
unsigned used_bits = 0;
decoder->private_->stream_info.type = type;
decoder->private_->stream_info.type = (FLAC__MetadataType)type;
decoder->private_->stream_info.is_last = last_block;
decoder->private_->stream_info.length = length;
......@@ -884,7 +884,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->client_data);
}
else if(type == FLAC__METADATA_TYPE_SEEKTABLE) {
decoder->private_->seek_table.type = type;
decoder->private_->seek_table.type = (FLAC__MetadataType)type;
decoder->private_->seek_table.is_last = last_block;
decoder->private_->seek_table.length = length;
......@@ -925,7 +925,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
FLAC__StreamMetadata block;
block.is_last = last_block;
block.type = type;
block.type = (FLAC__MetadataType)type;
block.length = length;
if(type == FLAC__METADATA_TYPE_APPLICATION) {
......@@ -952,7 +952,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
case FLAC__METADATA_TYPE_APPLICATION:
/* remember, we read the ID already */
if(real_length > 0) {
if(0 == (block.data.application.data = malloc(real_length))) {
if(0 == (block.data.application.data = (FLAC__byte*)malloc(real_length))) {
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
......@@ -968,7 +968,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
if(!FLAC__bitbuffer_read_raw_uint32_little_endian(decoder->private_->input, &block.data.vorbis_comment.vendor_string.length, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(block.data.vorbis_comment.vendor_string.length > 0) {
if(0 == (block.data.vorbis_comment.vendor_string.entry = malloc(block.data.vorbis_comment.vendor_string.length))) {
if(0 == (block.data.vorbis_comment.vendor_string.entry = (FLAC__byte*)malloc(block.data.vorbis_comment.vendor_string.length))) {
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
......@@ -985,7 +985,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
/* read comments */
if(block.data.vorbis_comment.num_comments > 0) {
if(0 == (block.data.vorbis_comment.comments = malloc(block.data.vorbis_comment.num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) {
if(0 == (block.data.vorbis_comment.comments = (FLAC__StreamMetadata_VorbisComment_Entry*)malloc(block.data.vorbis_comment.num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) {
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
......@@ -994,7 +994,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
if(!FLAC__bitbuffer_read_raw_uint32_little_endian(decoder->private_->input, &block.data.vorbis_comment.comments[i].length, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(block.data.vorbis_comment.comments[i].length > 0) {
if(0 == (block.data.vorbis_comment.comments[i].entry = malloc(block.data.vorbis_comment.comments[i].length))) {
if(0 == (block.data.vorbis_comment.comments[i].entry = (FLAC__byte*)malloc(block.data.vorbis_comment.comments[i].length))) {
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
......@@ -1640,7 +1640,7 @@ FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel,
/* read entropy coding method info */
if(!FLAC__bitbuffer_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->entropy_coding_method.type = u32;
subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32;
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
if(!FLAC__bitbuffer_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN, read_callback_, decoder))
......@@ -1714,7 +1714,7 @@ FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, un
/* read entropy coding method info */
if(!FLAC__bitbuffer_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->entropy_coding_method.type = u32;
subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32;
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
if(!FLAC__bitbuffer_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN, read_callback_, decoder))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment