Re: How to release memory allocated for MIDISendSysex ??
Re: How to release memory allocated for MIDISendSysex ??
- Subject: Re: How to release memory allocated for MIDISendSysex ??
- From: "Marco Hinic" <email@hidden>
- Date: Tue, 29 Aug 2006 11:19:42 +0200
It looks like we did miss this step.
Thanks for the hints.
We were freeing the pointer without restoring it!
Best regards,
>The MIDISysexSendRequest's data member is advanced as the data is sent.
>
>You'll need to store the malloc'd pointer separately and free *that*
>from the completion routine.
>
>Doug
>
>On Aug 24, 2006, at 09:40 , Kurt Revis wrote:
>> On Aug 24, 2006, at 7:09 AM, Marco Hinic wrote:
>>
>>> Our new application does use a lot of sysex messages.
>>>
>>> We are using MIDISendSysex function and the associated
>>> MIDISysexSendRequest structure to do so.
>>>
>>> For each message, a new data buffer is allocated with malloc and
>>> we also
>>> ceate a new MIDISysexSendRequest structure.
>>>
>>> Can we simply free the message data and delete
>>> MIDISysexSendRequest in
>>> the MIDICompletionProc ?
>>
>> That's exactly what you should do.
>>
>>> Deleting the MidiSysexSendRequest does not seems to cause any trouble
>>> but free'ing it's data leads to a message from the malloc that we are
>>> freeing a block that was not allocated by malloc or free'd twice.
>>> Is the
>>> free of the data automatic ? We removed the free but are afraid
>>> there's
>>> going to be memory leaks in some parts.
>>
>> CoreMIDI will NOT automatically free the data. (It has no way of
>> knowing that you originally used malloc() to allocate the buffer,
>> so it cannot safely call free() on it.) Your code must be doing
>> it, one way or another. Or maybe you're trashing the data pointer
>> before you call free() on it.
>
>--
>Doug Wyatt
>Core Audio, Apple
>
-----------------------------------------------------------
Marco Hinic (email@hidden)
ArKaos engine architect & CEO
http://www.arkaos.net
In cyberspace nobody knows you're a cat
-----------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden