testinterpreterplugin and primitive cleaning?

Ned Konz ned at bike-nomad.com
Mon May 19 18:21:16 UTC 2003


On Monday 19 May 2003 11:00 am, Ragnar Hojland Espinosa wrote:
> On Fri, May 16, 2003 at 07:02:05PM -0700, Ned Konz wrote:
> > On Friday 16 May 2003 05:24 pm, Ragnar Hojland Espinosa wrote:
> > > Inside a primitive's C code I have code that uses a library
> > > call which allocates memory and returns it to the caller.  I
> > > convert that to an oop, to be stored in an object.  How do I
> > > call the library cleanup code when the object is destroyed
> > > (GCed if you prefer)?
> >
> > So the library allocates the memory outside of Squeak? How do you
> > safely convert that to an oop?
>
> Half of the time I dont know what I'm doing, the other half I don't
> know what to do :)  This is what I've currently been able to figure
> out:

[snip code]

Ah, I understand. Yes, that's the standard idiom for doing this 
(allocate a ByteArray, and stick pointers to an externally allocated 
C struct and a string into it).

Just remember that you can't hold onto a pointer to this allocated 
ByteArray in your C code, as it can move around when allocation/GC 
happens.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list