[svn:parrot] r49596 - branches/generational_gc/src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Oct 20 06:25:17 UTC 2010


Author: bacek
Date: Wed Oct 20 06:25:17 2010
New Revision: 49596
URL: https://trac.parrot.org/parrot/changeset/49596

Log:
Add function to calculate allocated memory in Fixed_Size_Allocator

Modified:
   branches/generational_gc/src/gc/fixed_allocator.c
   branches/generational_gc/src/gc/fixed_allocator.h

Modified: branches/generational_gc/src/gc/fixed_allocator.c
==============================================================================
--- branches/generational_gc/src/gc/fixed_allocator.c	Wed Oct 20 06:25:08 2010	(r49595)
+++ branches/generational_gc/src/gc/fixed_allocator.c	Wed Oct 20 06:25:17 2010	(r49596)
@@ -98,6 +98,11 @@
 
 Free fixed size memory from Fixed_Allocator.
 
+=item C<size_t Parrot_gc_fixed_allocator_allocated_memory(PARROT_INTERP,
+Fixed_Allocator *allocator)>
+
+Calculate amount of memory allocated in Fixed_Allocator.
+
 =cut
 
 */
@@ -181,6 +186,23 @@
     pool_free(allocator->pools[index], data);
 }
 
+PARROT_EXPORT
+size_t
+Parrot_gc_fixed_allocator_allocated_memory(PARROT_INTERP,
+        ARGIN(Fixed_Allocator *allocator))
+{
+    ASSERT_ARGS(Parrot_gc_fixed_allocator_allocated_memory)
+    size_t total = 0;
+    size_t i     = 0;
+
+    for (i = 0; i < allocator->num_pools; i++) {
+        if (allocator->pools[i])
+            total += Parrot_gc_pool_allocated_size(interp, allocator->pools[i]);
+    }
+
+    return total;
+}
+
 /*
 
 =back

Modified: branches/generational_gc/src/gc/fixed_allocator.h
==============================================================================
--- branches/generational_gc/src/gc/fixed_allocator.h	Wed Oct 20 06:25:08 2010	(r49595)
+++ branches/generational_gc/src/gc/fixed_allocator.h	Wed Oct 20 06:25:17 2010	(r49596)
@@ -67,6 +67,12 @@
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
+size_t Parrot_gc_fixed_allocator_allocated_memory(PARROT_INTERP,
+    ARGIN(Fixed_Allocator *allocator))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_EXPORT
 void Parrot_gc_fixed_allocator_destroy(PARROT_INTERP,
     ARGFREE_NOTNULL(Fixed_Allocator *allocator))
         __attribute__nonnull__(1)
@@ -127,6 +133,10 @@
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(allocator))
+#define ASSERT_ARGS_Parrot_gc_fixed_allocator_allocated_memory \
+     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(allocator))
 #define ASSERT_ARGS_Parrot_gc_fixed_allocator_destroy \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \


More information about the parrot-commits mailing list