[svn:parrot] r47134 - branches/gc_massacre/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Sun May 30 08:26:56 UTC 2010
Author: bacek
Date: Sun May 30 08:26:56 2010
New Revision: 47134
URL: https://trac.parrot.org/parrot/changeset/47134
Log:
Add .is_owned method to Pool_Allocator
Modified:
branches/gc_massacre/src/gc/pool_allocator.c
branches/gc_massacre/src/gc/pool_allocator.h
Modified: branches/gc_massacre/src/gc/pool_allocator.c
==============================================================================
--- branches/gc_massacre/src/gc/pool_allocator.c Sun May 30 08:21:58 2010 (r47133)
+++ branches/gc_massacre/src/gc/pool_allocator.c Sun May 30 08:26:56 2010 (r47134)
@@ -162,6 +162,21 @@
++pool->num_free_objects;
}
+PARROT_EXPORT
+int
+Parrot_gc_pool_is_owned(ARGMOD(Pool_Allocator *pool), ARGMOD(void *data))
+{
+ ASSERT_ARGS(Parrot_gc_pool_is_owned)
+ Pool_Allocator_Arena *arena = pool->top_arena;
+ while (arena) {
+ if (((char*)data - (char*)arena) < GC_FIXED_SIZE_POOL_SIZE)
+ return 1;
+ arena = arena->prev;
+ }
+
+ return 0;
+}
+
static void
allocate_new_pool_arena(ARGMOD(Pool_Allocator *pool))
Modified: branches/gc_massacre/src/gc/pool_allocator.h
==============================================================================
--- branches/gc_massacre/src/gc/pool_allocator.h Sun May 30 08:21:58 2010 (r47133)
+++ branches/gc_massacre/src/gc/pool_allocator.h Sun May 30 08:26:56 2010 (r47134)
@@ -74,6 +74,15 @@
FUNC_MODIFIES(*pool)
FUNC_MODIFIES(*data);
+PARROT_EXPORT
+int Parrot_gc_pool_is_owned(
+ ARGMOD(Pool_Allocator *pool),
+ ARGMOD(void *data))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ FUNC_MODIFIES(*pool)
+ FUNC_MODIFIES(*data);
+
#define ASSERT_ARGS_Parrot_gc_destroy_pool_alloctor \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -84,6 +93,9 @@
#define ASSERT_ARGS_Parrot_gc_pool_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pool) \
, PARROT_ASSERT_ARG(data))
+#define ASSERT_ARGS_Parrot_gc_pool_is_owned __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(pool) \
+ , PARROT_ASSERT_ARG(data))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/gc/pool_allocator.c */
More information about the parrot-commits
mailing list