[svn:parrot] r49230 - branches/gc_massacre/src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Wed Sep 22 03:12:00 UTC 2010
Author: bacek
Date: Wed Sep 22 03:12:00 2010
New Revision: 49230
URL: https://trac.parrot.org/parrot/changeset/49230
Log:
Use String GC to allocated Buffers. Fixes c++ build.
Modified:
branches/gc_massacre/src/gc/gc_ms2.c
Modified: branches/gc_massacre/src/gc/gc_ms2.c
==============================================================================
--- branches/gc_massacre/src/gc/gc_ms2.c Wed Sep 22 03:11:51 2010 (r49229)
+++ branches/gc_massacre/src/gc/gc_ms2.c Wed Sep 22 03:12:00 2010 (r49230)
@@ -60,6 +60,12 @@
PARROT_DOES_NOT_RETURN
static void failed_allocation(unsigned int line, unsigned long size);
+PARROT_MALLOC
+PARROT_CAN_RETURN_NULL
+static Buffer* gc_ms2_allocate_buffer_header(PARROT_INTERP,
+ SHIM(size_t size))
+ __attribute__nonnull__(1);
+
static void gc_ms2_allocate_buffer_storage(PARROT_INTERP,
ARGIN(Buffer *str),
size_t size)
@@ -126,6 +132,11 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
+static void gc_ms2_free_buffer_header(PARROT_INTERP,
+ ARGFREE(Buffer *s),
+ SHIM(size_t size))
+ __attribute__nonnull__(1);
+
static void gc_ms2_free_bufferlike_header(SHIM_INTERP,
ARGFREE(Buffer *b),
SHIM(size_t size));
@@ -245,6 +256,8 @@
__attribute__nonnull__(1);
#define ASSERT_ARGS_failed_allocation __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_gc_ms2_allocate_buffer_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms2_allocate_buffer_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -282,6 +295,8 @@
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(list))
+#define ASSERT_ARGS_gc_ms2_free_buffer_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms2_free_bufferlike_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms2_free_fixed_size_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -405,12 +420,6 @@
=item C<static void gc_ms2_free_string_header(PARROT_INTERP, STRING *s)>
-=item C<static Buffer* gc_ms2_allocate_bufferlike_header(PARROT_INTERP, size_t
-size)>
-
-=item C<static void gc_ms2_free_bufferlike_header(PARROT_INTERP, Buffer *b,
-size_t size)>
-
=item C<static void* gc_ms2_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)>
=item C<static void gc_ms2_free_pmc_attributes(PARROT_INTERP, PMC *pmc)>
@@ -437,22 +446,6 @@
*/
-PARROT_MALLOC
-PARROT_CAN_RETURN_NULL
-static Buffer*
-gc_ms2_allocate_bufferlike_header(SHIM_INTERP, SHIM(size_t size))
-{
- ASSERT_ARGS(gc_ms2_allocate_bufferlike_header)
- return (Buffer*)calloc(sizeof (Buffer), 1);
-}
-
-static void
-gc_ms2_free_bufferlike_header(SHIM_INTERP, ARGFREE(Buffer *b), SHIM(size_t size))
-{
- ASSERT_ARGS(gc_ms2_free_bufferlike_header)
- if (b)
- free(b);
-}
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
@@ -574,8 +567,8 @@
interp->gc_sys->allocate_string_header = gc_ms2_allocate_string_header;
interp->gc_sys->free_string_header = gc_ms2_free_string_header;
- interp->gc_sys->allocate_bufferlike_header = gc_ms2_allocate_string_header;
- interp->gc_sys->free_bufferlike_header = gc_ms2_free_string_header;
+ interp->gc_sys->allocate_bufferlike_header = gc_ms2_allocate_buffer_header;
+ interp->gc_sys->free_bufferlike_header = gc_ms2_free_buffer_header;
interp->gc_sys->allocate_pmc_attributes = gc_ms2_allocate_pmc_attributes;
interp->gc_sys->free_pmc_attributes = gc_ms2_free_pmc_attributes;
@@ -759,6 +752,20 @@
Parrot_pmc_destroy(interp, pmc);
}
+/*
+=item C<gc_ms2_allocate_string_header()>
+
+=item C<gc_ms2_free_string_header()>
+
+=item C<static Buffer* gc_ms2_allocate_buffer_header(PARROT_INTERP, size_t
+size)>
+
+=item C<static void gc_ms2_free_buffer_header(PARROT_INTERP, Buffer *s, size_t
+size)>
+
+Allocate/free string/buffer headers.
+
+*/
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
@@ -808,6 +815,22 @@
}
}
+PARROT_MALLOC
+PARROT_CAN_RETURN_NULL
+static Buffer*
+gc_ms2_allocate_buffer_header(PARROT_INTERP, SHIM(size_t size))
+{
+ ASSERT_ARGS(gc_ms2_allocate_buffer_header)
+ return (Buffer*)gc_ms2_allocate_string_header(interp, 0);
+}
+
+static void
+gc_ms2_free_buffer_header(PARROT_INTERP, ARGFREE(Buffer *s), SHIM(size_t size))
+{
+ ASSERT_ARGS(gc_ms2_free_buffer_header)
+ gc_ms2_free_string_header(interp, (STRING*)s);
+}
+
/*
=item C<static int gc_ms2_is_string_ptr(PARROT_INTERP, void *ptr)>
More information about the parrot-commits
mailing list