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

Help needed with weakrefs.

Thread Next
Artur Bergman
June 29, 2001 14:02
Help needed with weakrefs.
Message ID:
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

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!


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About