[Gambas-devel] How to know if an object is allocated or freed ?
Laurent Carlier
lordheavy at ...141...
Tue Dec 14 23:48:18 CET 2004
Le Mardi 14 Décembre 2004 23:35, Daniel Campos a écrit :
> Mmmh... Once an object is freed its pointer becomes NULL, as GB.Unref()
> does it when reference count is zero... However if you have more than a
> pointer pointing to that "bad" object, may be you can try GB.Is()
>
> Regards,
>
> D. Campos
>
>
I store the object with :
static CBUFFER *Buff = NULL;
and the following code (Draw.Buffer(toto)) :
BEGIN_METHOD(DRAWING_buffer, GB_OBJECT buffer)
Buff = VARG(buffer);
if (GB.CheckObject((void *) Buff))
{
GB.Propagate();
}
END_METHOD
toto is redefined with toto = Screen.Grab()
In Draw.Line it segfault :
BEGIN_METHOD(DRAWING_draw, GB_INTEGER X1; GB_INTEGER Y1; GB_INTEGER X2;
GB_INTEGER Y2)
Sint16 x1, y1;
if (GB.CheckObject((void *) Buff))
{
GB.Propagate();
}
x1 = VARG(X1);
y1 = VARG(Y1);
LastX = VARG(X2);
LastY = VARG(Y2);
lineColor(GETSURFACE(Buff), x1, y1, LastX, LastY, CColor);
END_METHOD
it segfault with GB.CheckObject((void *) Buff) as Buff doesn't seem to be NULL
but only invalid !
--
Laurent Carlier
More information about the Devel
mailing list