Index: [thread] [date] [subject] [author]
  From: Andrew Apted <ajapted@netspace.net.au>
  To  : ggi-develop@eskimo.com
  Date: Sat, 17 Jul 1999 13:22:17 +1000

Re: Extensions

Kien Pham writes:

>  O.K. I have clarity now.
>  My exact question is what exactly is the point of
>  allowing extensions to Attach() to visuals multiple times
>  when all this does is increment a counter.

As far as I know, this is to allow other extensions (or even libraries
that sit on top of LibGGI) to Attach() extensions without having to
worry whether they are already attached, making coding of them simpler.

>  This is relevent because my extension needs to initialize
>  data the first time it is Attach()ed to a visual.
>  calls to my function will cause it to check the return
>  value of Attach()ed to see if the data is already 
>  initialized. After this, I have two options. One is to
>  immediately Detach() if the return value is greater than 1
>  and the other is to "unwind" all Detach()es at the end of
>  the program. I find this a bit cumbersome. If I don't
>  properly Detach(), the data will never be free()ed.

I'm no extension expert, but can't you just keep a counter of how 
many Attaches have been done, and initialized your data when
incrementing it from 0 -> 1, and free it when decrementing it from 
1 -> 0 ?

Cheers,
___________________________________________________
                                               \  /
  Andrew Apted   <ajapted@netspace.net.au>      \/
 

Index: [thread] [date] [subject] [author]