[Gambas-devel] Returning a reference to an array ...

Benoit Minisini gambas at ...1...
Tue Jan 13 00:28:16 CET 2009


On mardi 13 janvier 2009, Gareth Bult wrote:
> Arhrhrhr, sorry, I should've spotted that one.
>
> It's all looking pretty tight now, except for the Signal#11 I'm generating
> on my unref on the second pass through this routine .. I guess I'm
> misunderstanding memory management somewhere. First pass works fine, second
> pass not so good .. anything obvious?
>
> What's confusing me is I'm successfully refing and unrefing "dev", and I'm
> refing THIS->devices, however for some reason it doesn't like the unref.
> Should I not be using ref/unref on the array?
>

You must use GB.Ref() when storing an element into the object array, because 
you are accessing the array memory directly (this is faster).

But you must not use GB.Unref() when you unref the array, because this is done 
automatically when the array is destroyed. You don't know, when unreferencing 
the array, if it will be destroyed immediately or not.

-- 
Benoit Minisini




More information about the Devel mailing list