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 945a89030e5d97db8ec329eba219037a86f546e3..386fda9ab6ff596b414158d055a356946c248bfd 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 9c1831cfccba60a4e1194601407692e3e48372a3..eb464f91da3803214aa2c19988ac1bf99aa9a258 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 6cef09162ed0f2078849fbc4b1b90f2ad4af426d..7ebd52a387889dedcf5762bfdca77d3e0ebcccb5 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 4d98e684941db28cd942d1debd7d38f2ca60836a..3c13a4658cb6cecf33e3f8227765aeaccd4a12d4 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);