develooper Front page | perl.perl5.porters | Postings from May 2008

Downgrading PVMG to PV?

Thread Next
From:
Bram
Date:
May 5, 2008 07:23
Subject:
Downgrading PVMG to PV?
Message ID:
20080505162246.meyfo6b928gc4wkw@horde.wizbit.be
At the risk of asking a stupid question:

Is there a way to downgrade an SV that is PVMG to a normal PV?

That is:

Dump($sv) shows:

SV = PVMG(0x815c768) at 0x8150578
    REFCNT = 1
    FLAGS = (POK,pPOK)
    IV = 0
    NV = 0
    PV = 0x815cc90 ""\0
    CUR = 0
    LEN = 240

While I want it to show:

SV = PV(0x815c768) at 0x8150578
    REFCNT = 1
    FLAGS = (POK,pPOK)
    PV = 0x815cc90 ""\0
    CUR = 0
    LEN = 240


The ugly way seems to be:
    SvFLAGS(sv) = SVt_PV;

But is there a saner/safer way?

SvUPGRADE(sv, SVt_PV) won't work because SvUPGRADE is because SVt_PVMG
  > SVt_PV:
#define SvUPGRADE(sv, mt) (SvTYPE(sv) >= (mt) || (sv_upgrade(sv, mt), 1))


Any ideas?

Kind regards,

Bram




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