Author: chromatic
Date: Wed Mar 28 00:35:04 2007
New Revision: 17807
Modified:
trunk/include/parrot/caches.h
trunk/src/inter_create.c
trunk/src/objects.c
Log:
Free object cache during global destruction.
Modified: trunk/include/parrot/caches.h
==============================================================================
--- trunk/include/parrot/caches.h (original)
+++ trunk/include/parrot/caches.h Wed Mar 28 00:35:04 2007
@@ -38,6 +38,7 @@
void init_object_cache(Parrot_Interp interp);
void mark_object_cache(Parrot_Interp);
+void destroy_object_cache(Parrot_Interp);
#endif /* PARROT_CACHES_H_GUARD */
Modified: trunk/src/inter_create.c
==============================================================================
--- trunk/src/inter_create.c (original)
+++ trunk/src/inter_create.c Wed Mar 28 00:35:04 2007
@@ -8,7 +8,7 @@
=head1 DESCRIPTION
-Create or destroy a Parrot interpreter.c
+Create or destroy a Parrot interpreter
=head2 Functions
@@ -394,7 +394,7 @@
mem_sys_free(interp->arena_base);
interp->arena_base = NULL;
/* cache structure */
- mem_sys_free(interp->caches);
+ destroy_object_cache(interp);
/* packfile */
if (!Interp_flags_TEST(interp, PARROT_EXTERN_CODE_FLAG)) {
Modified: trunk/src/objects.c
==============================================================================
--- trunk/src/objects.c (original)
+++ trunk/src/objects.c Wed Mar 28 00:35:04 2007
@@ -1181,7 +1181,7 @@
=item void Parrot_invalidate_method_cache(Interp *, STRING *class)
-Clear method cache for the given class. If class is NULL caches for
+Clear method cache for the given class. If class is NULL, caches for
all classes are invalidated.
=cut
@@ -1203,6 +1203,19 @@
SET_NULL(mc->idx);
}
+void
+destroy_object_cache(Interp *interp)
+{
+ UINTVAL i;
+ Caches * const mc = interp->caches;
+
+ for (i = 0; i < mc->mc_size; i++) {
+ if (mc->idx[i])
+ mem_sys_free(mc->idx[i]);
+ }
+ mem_sys_free(mc);
+}
+
#define TBL_SIZE_MASK 0x1ff /* x bits 2..10 */
#define TBL_SIZE (1 + TBL_SIZE_MASK)