Skip to content

Commit

Permalink
Handle SV-flags more intelligently
Browse files Browse the repository at this point in the history
  • Loading branch information
Leont committed Aug 13, 2011
1 parent 1dd39ff commit 192f3d3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/File/Map.xs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,10 @@ static void croak_sys(pTHX_ const char* format) {
#define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)

static void reset_var(SV* var, struct mmap_info* info) {
int utf8 = SvUTF8(var);
SvPVX(var) = info->fake_address;
SvLEN(var) = 0;
SvCUR(var) = info->fake_length;
SvPOK_only(var);
if (utf8)
SvUTF8_on(var);
SvPOK_only_UTF8(var);
}

static void mmap_fixup(pTHX_ SV* var, struct mmap_info* info, const char* string, STRLEN len) {
Expand Down Expand Up @@ -231,6 +228,8 @@ static int mmap_write(pTHX_ SV* var, MAGIC* magic) {
}
else if (SvPVX(var) != info->fake_address)
mmap_fixup(aTHX_ var, info, SvPVX(var), SvCUR(var));
else
SvPOK_only_UTF8(var);
return 0;
}

Expand Down Expand Up @@ -336,6 +335,8 @@ static void check_new_variable(pTHX_ SV* var) {
sv_unmagic(var, PERL_MAGIC_uvar);
if (SvROK(var))
sv_unref_flags(var, SV_IMMEDIATE_UNREF);
if (SvNIOK(var))
SvNIOK_off(var);
if (SvPOK(var))
SvPV_free(var);
if (SvTYPE(var) < SVt_PVMG)
Expand Down

0 comments on commit 192f3d3

Please sign in to comment.