This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add SAVEFREECOPHH()
authorZefram <zefram@fysh.org>
Thu, 28 Oct 2010 21:01:11 +0000 (22:01 +0100)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 29 Oct 2010 00:51:44 +0000 (17:51 -0700)
Add the facility for the save stack to free (decrement the refcount of)
a COPHH*.

ext/XS-APItest/APItest.xs
scope.c
scope.h
sv.c

index 945a890..386fda9 100644 (file)
@@ -2065,7 +2065,9 @@ test_cophh()
        check_ph(cophh_fetch_pvs(a, "foo_\xc2\x8c", 0));
        check_iv(cophh_fetch_pvs(a, "foo_\xd9\xa6", COPHH_KEY_UTF8), 666);
        check_ph(cophh_fetch_pvs(a, "foo_\xd9\xa6", 0));
-       cophh_free(a);
+       ENTER;
+       SAVEFREECOPHH(a);
+       LEAVE;
 #undef check_ph
 #undef check_iv
 #undef msvpvs
diff --git a/scope.c b/scope.c
index 9c1831c..eb464f9 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -867,6 +867,10 @@ Perl_leave_scope(pTHX_ I32 base)
            ptr = SSPOPPTR;
            SvREFCNT_dec(MUTABLE_SV(ptr));
            break;
+       case SAVEt_FREECOPHH:
+           ptr = SSPOPPTR;
+           cophh_free((COPHH *)ptr);
+           break;
        case SAVEt_MORTALIZESV:
            ptr = SSPOPPTR;
            sv_2mortal(MUTABLE_SV(ptr));
diff --git a/scope.h b/scope.h
index 6cef091..7ebd52a 100644 (file)
--- a/scope.h
+++ b/scope.h
@@ -58,6 +58,7 @@
 #define SAVEt_I32_SMALL                47
 #define SAVEt_INT_SMALL                48
 #define SAVEt_GVSV             49
+#define SAVEt_FREECOPHH                50
 
 #define SAVEf_SETMAGIC         1
 #define SAVEf_KEEPOLDELEM      2
@@ -184,6 +185,7 @@ scope has the given name. Name must be a literal string.
 #define SAVEGENERICPV(s)       save_generic_pvref((char**)&(s))
 #define SAVESHAREDPV(s)                save_shared_pvref((char**)&(s))
 #define SAVESETSVFLAGS(sv,mask,val)    save_set_svflags(sv,mask,val)
+#define SAVEFREECOPHH(h)       save_pushptr((void *)(h), SAVEt_FREECOPHH)
 #define SAVEDELETE(h,k,l) \
          save_delete(MUTABLE_HV(h), (char*)(k), (I32)(l))
 #define SAVEHDELETE(h,s) \
diff --git a/sv.c b/sv.c
index 4d98e68..3c13a46 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12209,6 +12209,10 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param)
            else
                TOPPTR(nss,ix) = NULL;
            break;
+       case SAVEt_FREECOPHH:
+           ptr = POPPTR(ss,ix);
+           TOPPTR(nss,ix) = cophh_copy((COPHH *)ptr);
+           break;
        case SAVEt_DELETE:
            hv = (const HV *)POPPTR(ss,ix);
            TOPPTR(nss,ix) = hv_dup_inc(hv, param);