'libs/evoral' - cast the returned pointers from malloc() / g_ptr_array_index() etc, as needed to satisfy MSVC
This commit is contained in:
parent
1cb37fc11c
commit
453ed61c4a
@ -56,7 +56,7 @@ smf_new(void)
|
|||||||
{
|
{
|
||||||
int cantfail;
|
int cantfail;
|
||||||
|
|
||||||
smf_t *smf = malloc(sizeof(smf_t));
|
smf_t *smf = (smf_t*)malloc(sizeof(smf_t));
|
||||||
if (smf == NULL) {
|
if (smf == NULL) {
|
||||||
g_critical("Cannot allocate smf_t structure: %s", strerror(errno));
|
g_critical("Cannot allocate smf_t structure: %s", strerror(errno));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -89,7 +89,7 @@ smf_delete(smf_t *smf)
|
|||||||
{
|
{
|
||||||
/* Remove all the tracks, from last to first. */
|
/* Remove all the tracks, from last to first. */
|
||||||
while (smf->tracks_array->len > 0)
|
while (smf->tracks_array->len > 0)
|
||||||
smf_track_delete(g_ptr_array_index(smf->tracks_array, smf->tracks_array->len - 1));
|
smf_track_delete((smf_track_t*)g_ptr_array_index(smf->tracks_array, smf->tracks_array->len - 1));
|
||||||
|
|
||||||
smf_fini_tempo(smf);
|
smf_fini_tempo(smf);
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ smf_delete(smf_t *smf)
|
|||||||
smf_track_t *
|
smf_track_t *
|
||||||
smf_track_new(void)
|
smf_track_new(void)
|
||||||
{
|
{
|
||||||
smf_track_t *track = malloc(sizeof(smf_track_t));
|
smf_track_t *track = (smf_track_t*)malloc(sizeof(smf_track_t));
|
||||||
if (track == NULL) {
|
if (track == NULL) {
|
||||||
g_critical("Cannot allocate smf_track_t structure: %s", strerror(errno));
|
g_critical("Cannot allocate smf_track_t structure: %s", strerror(errno));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -135,7 +135,7 @@ smf_track_delete(smf_track_t *track)
|
|||||||
|
|
||||||
/* Remove all the events, from last to first. */
|
/* Remove all the events, from last to first. */
|
||||||
while (track->events_array->len > 0)
|
while (track->events_array->len > 0)
|
||||||
smf_event_delete(g_ptr_array_index(track->events_array, track->events_array->len - 1));
|
smf_event_delete((smf_event_t*)g_ptr_array_index(track->events_array, track->events_array->len - 1));
|
||||||
|
|
||||||
if (track->smf)
|
if (track->smf)
|
||||||
smf_track_remove_from_smf(track);
|
smf_track_remove_from_smf(track);
|
||||||
@ -217,7 +217,7 @@ smf_track_remove_from_smf(smf_track_t *track)
|
|||||||
smf_event_t *
|
smf_event_t *
|
||||||
smf_event_new(void)
|
smf_event_new(void)
|
||||||
{
|
{
|
||||||
smf_event_t *event = malloc(sizeof(smf_event_t));
|
smf_event_t *event = (smf_event_t*)malloc(sizeof(smf_event_t));
|
||||||
if (event == NULL) {
|
if (event == NULL) {
|
||||||
g_critical("Cannot allocate smf_event_t structure: %s", strerror(errno));
|
g_critical("Cannot allocate smf_event_t structure: %s", strerror(errno));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -250,7 +250,7 @@ smf_event_new_from_pointer(const void *midi_data, size_t len)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
event->midi_buffer_length = len;
|
event->midi_buffer_length = len;
|
||||||
event->midi_buffer = malloc(event->midi_buffer_length);
|
event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
|
||||||
if (event->midi_buffer == NULL) {
|
if (event->midi_buffer == NULL) {
|
||||||
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
|
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
|
||||||
smf_event_delete(event);
|
smf_event_delete(event);
|
||||||
@ -340,7 +340,7 @@ smf_event_new_from_bytes(int first_byte, int second_byte, int third_byte)
|
|||||||
}
|
}
|
||||||
|
|
||||||
event->midi_buffer_length = len;
|
event->midi_buffer_length = len;
|
||||||
event->midi_buffer = malloc(event->midi_buffer_length);
|
event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
|
||||||
if (event->midi_buffer == NULL) {
|
if (event->midi_buffer == NULL) {
|
||||||
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
|
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
|
||||||
smf_event_delete(event);
|
smf_event_delete(event);
|
||||||
@ -777,7 +777,7 @@ smf_track_get_event_by_number(const smf_track_t *track, size_t event_number)
|
|||||||
if (event_number > track->number_of_events)
|
if (event_number > track->number_of_events)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
event = g_ptr_array_index(track->events_array, event_number - 1);
|
event = (smf_event_t*)g_ptr_array_index(track->events_array, event_number - 1);
|
||||||
|
|
||||||
assert(event);
|
assert(event);
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ smf_event_decode_textual(const smf_event_t *event, const char *name)
|
|||||||
int off = 0;
|
int off = 0;
|
||||||
char *buf, *extracted;
|
char *buf, *extracted;
|
||||||
|
|
||||||
buf = malloc(BUFFER_SIZE);
|
buf = (char*)malloc(BUFFER_SIZE);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
g_critical("smf_event_decode_textual: malloc failed.");
|
g_critical("smf_event_decode_textual: malloc failed.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -181,7 +181,7 @@ smf_event_decode_metadata(const smf_event_t *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = malloc(BUFFER_SIZE);
|
buf = (char*)malloc(BUFFER_SIZE);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
g_critical("smf_event_decode_metadata: malloc failed.");
|
g_critical("smf_event_decode_metadata: malloc failed.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -239,7 +239,7 @@ smf_event_decode_metadata(const smf_event_t *event)
|
|||||||
|
|
||||||
off += snprintf(buf + off, BUFFER_SIZE - off,
|
off += snprintf(buf + off, BUFFER_SIZE - off,
|
||||||
"Time Signature: %d/%d, %d clocks per click, %d notated 32nd notes per quarter note",
|
"Time Signature: %d/%d, %d clocks per click, %d notated 32nd notes per quarter note",
|
||||||
event->midi_buffer[3], (int)pow(2, event->midi_buffer[4]), event->midi_buffer[5],
|
event->midi_buffer[3], (int)pow((double)2, event->midi_buffer[4]), event->midi_buffer[5],
|
||||||
event->midi_buffer[6]);
|
event->midi_buffer[6]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ smf_event_decode_system_realtime(const smf_event_t *event)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = malloc(BUFFER_SIZE);
|
buf = (char*)malloc(BUFFER_SIZE);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
g_critical("smf_event_decode_system_realtime: malloc failed.");
|
g_critical("smf_event_decode_system_realtime: malloc failed.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -358,7 +358,7 @@ smf_event_decode_sysex(const smf_event_t *event)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = malloc(BUFFER_SIZE);
|
buf = (char*)malloc(BUFFER_SIZE);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
g_critical("smf_event_decode_sysex: malloc failed.");
|
g_critical("smf_event_decode_sysex: malloc failed.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -459,7 +459,7 @@ smf_event_decode_system_common(const smf_event_t *event)
|
|||||||
if (smf_event_is_sysex(event))
|
if (smf_event_is_sysex(event))
|
||||||
return (smf_event_decode_sysex(event));
|
return (smf_event_decode_sysex(event));
|
||||||
|
|
||||||
buf = malloc(BUFFER_SIZE);
|
buf = (char*)malloc(BUFFER_SIZE);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
g_critical("smf_event_decode_system_realtime: malloc failed.");
|
g_critical("smf_event_decode_system_realtime: malloc failed.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -530,7 +530,7 @@ smf_event_decode(const smf_event_t *event)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = malloc(BUFFER_SIZE);
|
buf = (char*)malloc(BUFFER_SIZE);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
g_critical("smf_event_decode: malloc failed.");
|
g_critical("smf_event_decode: malloc failed.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -600,7 +600,7 @@ smf_decode(const smf_t *smf)
|
|||||||
int off = 0;
|
int off = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
buf = malloc(BUFFER_SIZE);
|
buf = (char*)malloc(BUFFER_SIZE);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
g_critical("smf_event_decode: malloc failed.");
|
g_critical("smf_event_decode: malloc failed.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -123,7 +123,7 @@ parse_mthd_header(smf_t *smf)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp_mthd = smf->file_buffer;
|
tmp_mthd = (chunk_header_struct*)smf->file_buffer;
|
||||||
|
|
||||||
if (!chunk_signature_matches(tmp_mthd, "MThd")) {
|
if (!chunk_signature_matches(tmp_mthd, "MThd")) {
|
||||||
g_critical("SMF error: MThd signature not found, is that a MIDI file?");
|
g_critical("SMF error: MThd signature not found, is that a MIDI file?");
|
||||||
@ -409,7 +409,7 @@ extract_sysex_event(const unsigned char *buf, const size_t buffer_length, smf_ev
|
|||||||
}
|
}
|
||||||
|
|
||||||
event->midi_buffer_length = message_length;
|
event->midi_buffer_length = message_length;
|
||||||
event->midi_buffer = malloc(event->midi_buffer_length);
|
event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
|
||||||
if (event->midi_buffer == NULL) {
|
if (event->midi_buffer == NULL) {
|
||||||
g_critical("Cannot allocate memory in extract_sysex_event(): %s", strerror(errno));
|
g_critical("Cannot allocate memory in extract_sysex_event(): %s", strerror(errno));
|
||||||
return (-4);
|
return (-4);
|
||||||
@ -452,7 +452,7 @@ extract_escaped_event(const unsigned char *buf, const size_t buffer_length, smf_
|
|||||||
}
|
}
|
||||||
|
|
||||||
event->midi_buffer_length = message_length;
|
event->midi_buffer_length = message_length;
|
||||||
event->midi_buffer = malloc(event->midi_buffer_length);
|
event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
|
||||||
if (event->midi_buffer == NULL) {
|
if (event->midi_buffer == NULL) {
|
||||||
g_critical("Cannot allocate memory in extract_escaped_event(): %s", strerror(errno));
|
g_critical("Cannot allocate memory in extract_escaped_event(): %s", strerror(errno));
|
||||||
return (-4);
|
return (-4);
|
||||||
@ -522,7 +522,7 @@ extract_midi_event(const unsigned char *buf, const size_t buffer_length, smf_eve
|
|||||||
}
|
}
|
||||||
|
|
||||||
event->midi_buffer_length = message_length;
|
event->midi_buffer_length = message_length;
|
||||||
event->midi_buffer = malloc(event->midi_buffer_length);
|
event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
|
||||||
if (event->midi_buffer == NULL) {
|
if (event->midi_buffer == NULL) {
|
||||||
g_critical("Cannot allocate memory in extract_midi_event(): %s", strerror(errno));
|
g_critical("Cannot allocate memory in extract_midi_event(): %s", strerror(errno));
|
||||||
return (-4);
|
return (-4);
|
||||||
@ -611,7 +611,7 @@ make_string(const unsigned char *buf, const size_t buffer_length, uint32_t len)
|
|||||||
len = buffer_length;
|
len = buffer_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
str = malloc(len + 1);
|
str = (char*)malloc(len + 1);
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
g_critical("Cannot allocate memory in make_string().");
|
g_critical("Cannot allocate memory in make_string().");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -662,14 +662,14 @@ smf_event_extract_text(const smf_event_t *event)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
smf_extract_vlq((void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length);
|
smf_extract_vlq((const unsigned char*)(void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length);
|
||||||
|
|
||||||
if (string_length <= 0) {
|
if (string_length <= 0) {
|
||||||
g_critical("smf_event_extract_text: truncated MIDI message.");
|
g_critical("smf_event_extract_text: truncated MIDI message.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (make_string((void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length));
|
return (make_string((const unsigned char*)(void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +58,7 @@ static void *
|
|||||||
smf_extend(smf_t *smf, const int length)
|
smf_extend(smf_t *smf, const int length)
|
||||||
{
|
{
|
||||||
int i, previous_file_buffer_length = smf->file_buffer_length;
|
int i, previous_file_buffer_length = smf->file_buffer_length;
|
||||||
char *previous_file_buffer = smf->file_buffer;
|
char *previous_file_buffer = (char*)smf->file_buffer;
|
||||||
|
|
||||||
/* XXX: Not terribly efficient. */
|
/* XXX: Not terribly efficient. */
|
||||||
smf->file_buffer_length += length;
|
smf->file_buffer_length += length;
|
||||||
@ -205,7 +205,7 @@ smf_event_new_textual(int type, const char *text)
|
|||||||
|
|
||||||
/* "2 +" is for leading 0xFF 0xtype. */
|
/* "2 +" is for leading 0xFF 0xtype. */
|
||||||
event->midi_buffer_length = 2 + text_length + MAX_VLQ_LENGTH;
|
event->midi_buffer_length = 2 + text_length + MAX_VLQ_LENGTH;
|
||||||
event->midi_buffer = malloc(event->midi_buffer_length);
|
event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
|
||||||
if (event->midi_buffer == NULL) {
|
if (event->midi_buffer == NULL) {
|
||||||
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
|
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
|
||||||
smf_event_delete(event);
|
smf_event_delete(event);
|
||||||
|
@ -59,7 +59,7 @@ new_tempo(smf_t *smf, size_t pulses)
|
|||||||
return (previous_tempo);
|
return (previous_tempo);
|
||||||
}
|
}
|
||||||
|
|
||||||
tempo = malloc(sizeof(smf_tempo_t));
|
tempo = (smf_tempo_t*)malloc(sizeof(smf_tempo_t));
|
||||||
if (tempo == NULL) {
|
if (tempo == NULL) {
|
||||||
g_critical("Cannot allocate smf_tempo_t.");
|
g_critical("Cannot allocate smf_tempo_t.");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -152,7 +152,7 @@ maybe_add_to_tempo_map(smf_event_t *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
numerator = event->midi_buffer[3];
|
numerator = event->midi_buffer[3];
|
||||||
denominator = (int)pow(2, event->midi_buffer[4]);
|
denominator = (int)pow((double)2, event->midi_buffer[4]);
|
||||||
clocks_per_click = event->midi_buffer[5];
|
clocks_per_click = event->midi_buffer[5];
|
||||||
notes_per_note = event->midi_buffer[6];
|
notes_per_note = event->midi_buffer[6];
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ smf_get_tempo_by_number(const smf_t *smf, size_t number)
|
|||||||
if (number >= smf->tempo_array->len)
|
if (number >= smf->tempo_array->len)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
return (g_ptr_array_index(smf->tempo_array, number));
|
return ((smf_tempo_t*)g_ptr_array_index(smf->tempo_array, number));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -341,7 +341,7 @@ smf_fini_tempo(smf_t *smf)
|
|||||||
smf_tempo_t *tempo;
|
smf_tempo_t *tempo;
|
||||||
|
|
||||||
while (smf->tempo_array->len > 0) {
|
while (smf->tempo_array->len > 0) {
|
||||||
tempo = g_ptr_array_index(smf->tempo_array, smf->tempo_array->len - 1);
|
tempo = (smf_tempo_t*)g_ptr_array_index(smf->tempo_array, smf->tempo_array->len - 1);
|
||||||
assert(tempo);
|
assert(tempo);
|
||||||
|
|
||||||
memset(tempo, 0, sizeof(smf_tempo_t));
|
memset(tempo, 0, sizeof(smf_tempo_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user