On 27/08/2012 17:11, Tobias Burnus wrote:
>> could you add comments
>> in gfortran.h telling which pointers account for reference counting?
>> As far as I remember for symbols, there are:
>>    gfc_symtree::n::sym;
>>    gfc_namespace::proc_name;
> 
> Well, I have still not gained a full overview about refs, but there are
> refs in gfc_namespace, gfc_symbol and (new) in gfc_common_head.
> 
> 
> The latter is easy: For each symbol in the (named) common block, the
> refs is incremented, and in gfc_free_symbol it is decremented and
> deleted if refs == 1. [For blank commons, gfc_namespace contains a
> nonpointer gfc_common_head field.]
> 
> 
> For namespaces, refs gets set to 1 at creation in gfc_get_namespace; it
> gets incremented if the ns is used by a sym->formal_ns (unless
> sym->formal_ns == sym->ns);  the formal_ns gets freed if
> sym->formal_ns->refs == 2. And gfc_free_namespace decrements its refs -
> and frees the namespace if refs == 1 (before the decrement). There is
> also in module.c a mio_namespace_ref which refs++. The latter and the
> similar code in resolve.c is needed for (quoting gfortran.h):
> 
>   /* Normally we don't need to refcount namespaces.  However when we read
>      a module containing a function with multiple entry points, this
>      will appear as several functions with the same formal namespace.  */
> 
> 
> And for gfc_symbol->refs: That get's always incremented when the symbol
> is referenced, and decremented if the a symbol is released.
> 
> 
> Actually, it is unclear to me what kind of comment you would like to see
> in gfortran.h.

Well, the information you provided above.  But it seems the comment is
already present.

Mikael

Reply via email to