I keep on receiving this error (topic title) in MIOS32 after switching between sections via my ngr script which proceeds to request store SysEx dumps from a connected synth.
I have a firm belief about what probably causes the error (the error I could not resolve by research, though.. the term malloc just leads me to think, that there is some memory that is not being freed properly after use)
What I did in my c files was introducing a new kind of variable (called ^macdis) for use in SysEx stream sending. What it does is that it resolves a value from a sysEx dump (identified by syxdump_pos:x:y) into a 6-field u8 array to be further used for sending it to a Mackie C4, which uses it to display the value on six fields of one of its displays. I herefore instanciate a u8[6] array here:
s32 MBNG_EVENT_SendSysExStream(mios32_midi_port_t port, mbng_event_item_t *item)
{
u8 *stream_in = item->stream;
u32 stream_size = item->stream_size;
s16 item_value = item->value;
//initialize array and pointer for the 6-field Display values
u8 *macdis_array;
macdis_array = (u8 *)malloc(sizeof(u8)*6);
…
And I have a feeling that I just did not fully get my head around the whole pointer thing. After repeatedly calling my ngr section 1, which requests and receives the dump and subsequently uses the ^macdis flag to print one value on the mackie (and herefore using the array, which I want to be ONE array, that is cleared after the processing of one incoming value and then used for the next) the error comes up and the whole thing crashes of course. Here is how the (relevant part of) code in mbng_event.c goes on:
case MBNG_EVENT_SYSEX_VAR_MACDIS: {
int i, j, rest;
u8 num = item_value;
for(i=5;i>=0;i–){
if(i == 0 || i == 4 || i == 5){
macdis_array = 0x2d;
}
else{
if(num > 0){
rest = num%10;
num /= 10;
switch(rest){
case 0: macdis_array = 0x30; break;
case 1: macdis_array = 0x31; break;
case 2: macdis_array = 0x32; break;
case 3: macdis_array = 0x33; break;
case 4: macdis_array = 0x34; break;
case 5: macdis_array = 0x35; break;
case 6: macdis_array = 0x36; break;
case 7: macdis_array = 0x37; break;
case 8: macdis_array = 0x38; break;
case 9: macdis_array = 0x39; break;
default: macdis_array = 0x2d; break;
}
}
else{
macdis_array = 0x30;
}
}
}
for(j=0;j<6;j++){
MBNG_EVENT_ADD_STREAM(macdis_array[j] & 0x7f);
}
} break;
Since I cannot resolve the error by reasearch I would be grateful for anyone, who might take a quick glance at my code. Maybe someone, who is a bit more experienced in C than I am might see the (possibly obvious) error