[Gambas-devel] How to know if an object is allocated or freed ?

Laurent Carlier lordheavy at ...141...
Tue Dec 14 22:39:13 CET 2004


Le Mardi 14 Décembre 2004 22:16, Laurent Carlier a écrit :
> How can i know if an object was freed ?
>
> GB.CheckObject test only if it's null.
> It's should be good for me to avoid segfault.
>
> code :
> PUBLIC SUB Main()
>
>   DIM toto AS Buffer
>
>   Screen(800,600,32)
>   toto = NEW Buffer(800,600,32)
>
>   Draw.Buffer(toto)
>   toto = Screen.Grab()
>   Draw.Line(0,0,100,100)
>   WAIT 3
>
> END
>
> it segfault as toto has been freed but isn't a null object !
> How can i know if it was freed ?
> Perhaps an int GB.IsAllocated(void** object) function should be usefull.
>
> Regards,

it's segfault when i try to test toto previously store at Draw.Buffer(toto) 
with this piece of code (in the Draw.Line function):

  if (GB.CheckObject((void *) Buff))
  {
    GB.Propagate();
  } 

-- 

Laurent Carlier




More information about the Devel mailing list