parrotcode: Allocate and deallocate tracked resources | |
Contents | C |
src/resources.c - Allocate and deallocate tracked resources
static void *alloc_new_block(Interp *interp, size_t size, struct Memory_Pool *pool, const char *why)
static void *mem_allocate(Interp *, size_t size, struct Memory_Pool *pool)
+-----------------+
| ref_count |f | # GC header
obj->bufstart -> +-----------------+
| data |
v v
* if PObj_is_COWable is set, then we have
- a ref_count, {inc,dec}remented by 2 always
- the lo bit 'f' means 'is being forwarded" - what TAIL_flag was
* if PObj_align_FLAG is set, obj->bufstart is aligned like discussed above
* obj->buflen is the usable length excluding the optional GC part.
static void compact_pool(Interp *interp, struct Memory_Pool *pool)
void Parrot_go_collect(Interp *interp)
void Parrot_reallocate(Interp *interp, Buffer *from, size_t tosize)
void Parrot_reallocate_string(Interp *interp, STRING *str, size_t tosize)
str->strstart
to the new buffer location, str->bufused
is not changed.void Parrot_allocate(Interp *interp, Buffer *buffer, size_t size)
size
has to be a multiple of the word size. PObj_buflen
will be set to exactly the given size
.void Parrot_allocate_aligned(Interp *interp, Buffer *buffer, size_t size)
size
will be rounded up and the address of the buffer will have the same alignment as a pointer returned by malloc(3) suitable to hold e.g. a FLOATVAL
array.void Parrot_allocate_string(Interp *interp, STRING *str, size_t size)
size
. This function sets also str->strstart
to the new buffer location, str->bufused
is not changed.static struct Memory_Pool *new_memory_pool(size_t min_block, compact_f compact)
void Parrot_initialize_memory_pools(Interp *interp)
void Parrot_destroy_memory_pools(Interp *interp)
void Parrot_merge_memory_pools(Interp *dest_interp, Interp *source_interp)
source_interp
into dest_interp
.include/parrot/resources.h, src/memory.c.
Initial version by Dan on 2001.10.2.
|