[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] reading an array from lang to C

On Dec 16, 2003, at 5:06 AM, Ronald J. Kuivila wrote:

Thanks James, clearly I'm just too used closures in SC...

I am copying the Int8Array for fear of garbage collection.
It would certainly be more efficient to use it directly.
Is there some legal way to suspend gc on the array and then
have the completion routine restore it?


You could keep a reference to it by storing it in a classvar. SCWindow and UnixFILE both have classvars that contain an Array of all open windows/files. This prevents them from being garbage collected as long as the C object they contain is not closed.

However this may not be the best way. You are also going to need to store the MIDISysexSendRequest until the completion call. I suggest just mallocing both the buffer and the MIDISysexSendRequest and freeing them in the completion routine. There's a copy, but this way you don't have to deal with the classvar stuff.

--- james mccartney   james@xxxxxxxxxxxxxx   <http://www.audiosynth.com>
SuperCollider - a real time audio synthesis programming language