[svn:parrot] r44088 - branches/sys_mem_reduce/src/dynpmc

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Feb 17 10:30:45 UTC 2010


Author: bacek
Date: Wed Feb 17 10:30:45 2010
New Revision: 44088
URL: https://trac.parrot.org/parrot/changeset/44088

Log:
Switch Rational PMC to auto_attrs and GC allocations.

Modified:
   branches/sys_mem_reduce/src/dynpmc/rational.pmc

Modified: branches/sys_mem_reduce/src/dynpmc/rational.pmc
==============================================================================
--- branches/sys_mem_reduce/src/dynpmc/rational.pmc	Wed Feb 17 10:30:21 2010	(r44087)
+++ branches/sys_mem_reduce/src/dynpmc/rational.pmc	Wed Feb 17 10:30:45 2010	(r44088)
@@ -227,7 +227,7 @@
 
 */
 
-pmclass Rational dynpmc provides scalar {
+pmclass Rational dynpmc provides scalar auto_attrs {
     ATTR struct RATIONAL *rational;
 /*
 
@@ -265,9 +265,8 @@
     VTABLE void init() {
       #ifdef PARROT_HAS_GMP
         Parrot_Rational_attributes *attrs =
-            mem_allocate_zeroed_typed(Parrot_Rational_attributes);
-        PMC_data(SELF)     = attrs;
-        PMC_rational(SELF) = (RATIONAL *)malloc(sizeof (RATIONAL));
+            PARROT_RATIONAL(SELF);
+        attrs->rational = gc_mem_allocate_zeroed_typed(INTERP, RATIONAL);
         mpq_init(RT(SELF));
         PObj_custom_destroy_SET(SELF);
       #endif
@@ -300,9 +299,7 @@
     VTABLE void destroy() {
       #ifdef PARROT_HAS_GMP
         mpq_clear(RT(SELF));
-        mem_sys_free(RT(SELF));
-        mem_sys_free(PMC_data(SELF));
-        PMC_data(SELF) = NULL;
+        gc_mem_free(INTERP, RT(SELF));
       #else
         RAISE_EXCEPTION
       #endif


More information about the parrot-commits mailing list