[svn:parrot] r44373 - trunk/src

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Feb 23 09:02:51 UTC 2010


Author: bacek
Date: Tue Feb 23 09:02:50 2010
New Revision: 44373
URL: https://trac.parrot.org/parrot/changeset/44373

Log:
Switch hash to GC allocations

Modified:
   trunk/src/hash.c

Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c	Tue Feb 23 09:02:29 2010	(r44372)
+++ trunk/src/hash.c	Tue Feb 23 09:02:50 2010	(r44373)
@@ -750,11 +750,13 @@
     /* resize mem */
     if (old_offset != old_mem) {
         /* This buffer has been reallocated at least once before. */
-        new_mem = (HashBucket *)mem_sys_realloc(old_mem, HASH_ALLOC_SIZE(new_size));
+        new_mem = (HashBucket *)Parrot_gc_reallocate_memory_chunk_with_interior_pointers(
+                interp, old_mem, HASH_ALLOC_SIZE(new_size), HASH_ALLOC_SIZE(old_size));
     }
     else {
         /* Allocate a new buffer. */
-        new_mem = (HashBucket *)mem_sys_allocate(HASH_ALLOC_SIZE(new_size));
+        new_mem = (HashBucket *)Parrot_gc_allocate_memory_chunk_with_interior_pointers(
+                interp, HASH_ALLOC_SIZE(new_size));
         memcpy(new_mem, old_mem, HASH_ALLOC_SIZE(old_size));
     }
 
@@ -951,7 +953,8 @@
 {
     ASSERT_ARGS(parrot_create_hash)
     HashBucket  *bp;
-    void        *alloc = mem_sys_allocate(sizeof (Hash) + HASH_ALLOC_SIZE(INITIAL_BUCKETS));
+    void        *alloc = Parrot_gc_allocate_memory_chunk_with_interior_pointers(
+                            interp, sizeof (Hash) + HASH_ALLOC_SIZE(INITIAL_BUCKETS));
     Hash * const hash  = (Hash*)alloc;
     size_t       i;
 
@@ -1010,13 +1013,13 @@
 
 PARROT_EXPORT
 void
-parrot_hash_destroy(SHIM_INTERP, ARGMOD(Hash *hash))
+parrot_hash_destroy(PARROT_INTERP, ARGMOD(Hash *hash))
 {
     ASSERT_ARGS(parrot_hash_destroy)
     HashBucket *bp = (HashBucket*)((char*)hash + sizeof (Hash));
     if (bp != hash->bs)
-        mem_sys_free(hash->bs);
-    mem_sys_free(hash);
+        mem_gc_free(interp, hash->bs);
+    mem_gc_free(interp, hash);
 }
 
 
@@ -1040,8 +1043,8 @@
     for (i = 0; i <= hash->mask; i++) {
         HashBucket *bucket = hash->bi[i];
         while (bucket) {
-            mem_sys_free(bucket->key);
-            mem_sys_free(bucket->value);
+            mem_gc_free(interp, bucket->key);
+            mem_gc_free(interp, bucket->value);
             bucket = bucket->next;
         }
     }
@@ -1075,7 +1078,7 @@
     for (i = 0; i <= hash->mask; i++) {
         HashBucket *bucket = hash->bi[i];
         while (bucket) {
-            mem_sys_free(bucket->key);
+            mem_gc_free(interp, bucket->key);
             func(bucket->value);
             bucket = bucket->next;
         }


More information about the parrot-commits mailing list