summaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-04-09 13:22:22 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:57 +0200
commitd0d1d875e73eddbe65d30fccf7bb8cdffd6b83f2 (patch)
tree5ebd605ed98395f54be02204aacb9bf2b1a22ccb /malloc.c
parent00ee2f7451eed8bd1cceda8001df1722067c9f17 (diff)
2011-04-09 Ivan Maidanski <ivmai@mail.ru>
* mallocx.c (GC_malloc_uncollectable): Move to malloc.c (since it is used internally in some places).
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/malloc.c b/malloc.c
index 781d65a..fceb9dc 100644
--- a/malloc.c
+++ b/malloc.c
@@ -264,6 +264,57 @@ GC_API void * GC_CALL GC_generic_malloc(size_t lb, int k)
}
}
+/* Allocate lb bytes of pointerful, traced, but not collectable data */
+GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb)
+{
+ void *op;
+ void **opp;
+ size_t lg;
+ DCL_LOCK_STATE;
+
+ if( SMALL_OBJ(lb) ) {
+ if (EXTRA_BYTES != 0 && lb != 0) lb--;
+ /* We don't need the extra byte, since this won't be */
+ /* collected anyway. */
+ lg = GC_size_map[lb];
+ opp = &(GC_uobjfreelist[lg]);
+ LOCK();
+ if( (op = *opp) != 0 ) {
+ *opp = obj_link(op);
+ obj_link(op) = 0;
+ GC_bytes_allocd += GRANULES_TO_BYTES(lg);
+ /* Mark bit ws already set on free list. It will be */
+ /* cleared only temporarily during a collection, as a */
+ /* result of the normal free list mark bit clearing. */
+ GC_non_gc_bytes += GRANULES_TO_BYTES(lg);
+ UNLOCK();
+ } else {
+ UNLOCK();
+ op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE);
+ /* For small objects, the free lists are completely marked. */
+ }
+ GC_ASSERT(0 == op || GC_is_marked(op));
+ return((void *) op);
+ } else {
+ hdr * hhdr;
+
+ op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE);
+ if (0 == op) return(0);
+
+ GC_ASSERT(((word)op & (HBLKSIZE - 1)) == 0); /* large block */
+ hhdr = HDR(op);
+ /* We don't need the lock here, since we have an undisguised */
+ /* pointer. We do need to hold the lock while we adjust */
+ /* mark bits. */
+ LOCK();
+ set_mark_bit_from_hdr(hhdr, 0); /* Only object. */
+ GC_ASSERT(hhdr -> hb_n_marks == 0);
+ hhdr -> hb_n_marks = 1;
+ UNLOCK();
+ return((void *) op);
+ }
+}
+
#ifdef REDIRECT_MALLOC
# ifndef MSWINCE