Author: leo
Date: Wed Apr 20 06:17:48 2005
New Revision: 7894

Modified:
   trunk/classes/hash.pmc
Log:
fix GC bug with hash iterators

* a file static was used for return values from iterators



Modified: trunk/classes/hash.pmc
==============================================================================
--- trunk/classes/hash.pmc      (original)
+++ trunk/classes/hash.pmc      Wed Apr 20 06:17:48 2005
@@ -20,7 +20,6 @@
 
 
 /* These are set in class_init */
-static PMC* intret;
 
 /*
 
@@ -151,9 +150,6 @@
 
     void class_init() {
         make_bufferlike_pool(INTERP, sizeof(struct _hash));
-        if (pass) {
-            intret = get_integer_pmc(INTERP, 
Parrot_base_vtables[entry]->base_type);
-        }
     }
 
 /*
@@ -615,23 +611,24 @@
         Hash *hash = PMC_struct_val(SELF);
         HashBucket *b;
         PMC* nextkey;
+        PMC* result;
 
         switch (PObj_get_FLAGS(key) & KEY_type_FLAGS) {
-            case KEY_hash_iterator_FLAGS: {
+            case KEY_hash_iterator_FLAGS:
                 /* called from iterator with an integer idx in key
                  * check if we really have Hash_key_type_int
                  */
                 if (hash->key_type == Hash_key_type_int) {
                     INTVAL i = (INTVAL)hash_get_idx(INTERP, hash, key);
-                    PMC_int_val(intret) = i;
-                    return intret;
+                    result = pmc_new(INTERP, enum_class_Integer);
+                    PMC_int_val(result) = i;
                 }
                 else {
                     STRING *s = hash_get_idx(INTERP, hash, key);
-                    VTABLE_set_string_native(INTERP, intret, s);
-                    return intret;
+                    result = pmc_new(INTERP, enum_class_String);
+                    VTABLE_set_string_native(INTERP, result, s);
                 }
-           }
+                return result;
             default:
                 keystr = make_hash_key(INTERP, key);
         }

Reply via email to