develooper Front page | perl.perl5.porters | Postings from June 2001

Help needed with weakrefs.

Thread Next
From:
Artur Bergman
Date:
June 29, 2001 14:02
Subject:
Help needed with weakrefs.
Message ID:
B762B96D.1CB8%artur@contiller.se
Ok, I am so totally lost with regards to weakrefs.


It seems like a weakref realy also is a weakref to itself because the
referants backref magic array is a list of the weakrefs, but they are not
refcounted.

However this breaks badly with regard to duplicating the tree because the
refcount of the weakref (not the referant) goes way up too much.

The revleant stuff is in mg_dup which calls

sv_dup_inc(mg->mg_obj,param); which essentially copies the array and the
weakrefs, which already are duped so they are copied from the ptr table and
are refcount incremented. Trying to decrement the refcount here is not
possible since the real weakref might not have been cloned yet.

The other approach is to fix this from sv_dup case SVt_RV, but here the
refcount is 0. What makes it jump up I don't know.

One solution that should work would be to just bundle up all weakrefs and
then after all cloning is down decrement the refcount for each item. This
seems like a rather uhm, backward way of doing it, and I am not 100% sure it
is possible to do it this way.

Any suggestions are warmly welcomed!

Artur


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About