[Glass] How can I release a malloced CByteArray ....

itlists at schrievkrom.de itlists at schrievkrom.de
Wed Feb 26 08:28:49 PST 2014


Hmmm,

I thought that if I talk to an external library it is very good
programming practice that each component is responsible for allocating
and freeing their memory. This is very true, if both systems are working
with different memory allocation libraries.

That means, if I give a malloced memory to an external library the
external library should not free "my" memory.

Marten


Am 26.02.2014 17:12, schrieb James Foster:
> The short answer is “you can’t!” As indicated in the method comment, this is intended to be used to pass to C functions that take responsibility for freeing the memory. In most cases you should use CByteArray class>>#'gcMalloc:’ so that the external memory is freed automatically when the object is no longer referenced within Smalltalk.
> 



-- 
Marten Feldtmann


More information about the Glass mailing list