in reply to Is it possible to obtain all hardreferences to some memory address by knowing only one of them?

Consult sv.c about the arenas. This is where everything perl manages is managed. You'll write some C which can be used by the visit() function. That function can find your SV heads where SvANY() == your pointer. I'd guess you'd zero the refcount and call sv_clear on it then. I've included a copy of a simple function that uses visit() just so you can see how short and easy this can be.

visit(do_report_used, 0, 0); static void do_report_used(pTHX_ SV *sv) { if (SvTYPE(sv) != SVTYPEMASK) { PerlIO_printf(Perl_debug_log, "****\n"); sv_dump(sv); } }

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

  • Comment on Re: Is it possible to obtain all hardreferences to some memory address by knowing only one of them?
  • Download Code

Replies are listed 'Best First'.
Re^2: Is it possible to obtain all hardreferences to some memory address by knowing only one of them?
by dave_the_m (Monsignor) on Feb 07, 2007 at 17:54 UTC
    Except that isn't part of the Perl API and is subject to change, so it's not to be recommended. Also, visit() is a static function which can't be used outside of sv.c, and who's prototype has changed between 5.8.0 and 5.8.8.

    To answer the OP: no, there's no official way to achieve this.

    Dave.

      It's still a better way to accomplish this dubious goal than other ways. At least this way the infrastructure for walking this stuff is getting used. Now the OP can expect breakage between versions of perl...

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊