NAME
src/gc/res_lea.c - Resource allocation using malloc
DESCRIPTION
This file provides alternative implementations of memory allocation function found in src/resources.c.
It is used if Configure.pl is passed the --gc=malloc
or --gc=malloc-trace
options.
The "lea" in the file name refers to Doug Lea, who wrote malloc implementation found in src/malloc.c.
As of May 14, 2007, it doesn't work (and hasn't worked for some time.) The problem appears to be related to strings, but actually could be somewhere else. This allocator does not support any of Parrot's Copy-on-Write schemes. Nor does the string allocator handle "external" strings.
Functions
void Parrot_go_collect(PARROT_INTERP)
Does nothing other than increment the interpreter's static PARROT_INLINE void *xmalloc(size_t size)
Obtains the memory from static PARROT_INLINE void *xcalloc(size_t n, size_t size)
Obtains the memory from static PARROT_INLINE void *xrealloc(void *p, size_t size)
Reallocates the memory with void Parrot_reallocate(PARROT_INTERP, Buffer *buffer, size_t newsize)
COWable objects (strings or Buffers) use an INTVAL before void Parrot_allocate(PARROT_INTERP, Buffer *buffer, size_t size)
Allocate buffer memory for the given Buffer pointer.
The void Parrot_allocate_aligned(PARROT_INTERP, Buffer *buffer, size_t size)
Like above,
except the address of the buffer is guaranteed to be suitably aligned for holding anything contained in UnionVal (such as FLOATVAL).
void Parrot_reallocate_string(PARROT_INTERP, STRING *str, size_t newsize)
Reallocates the string buffer in void Parrot_allocate_string(PARROT_INTERP, STRING *str, size_t size)
Allocates the string buffer in void Parrot_initialize_memory_pools(PARROT_INTERP)
Does nothing.
void Parrot_merge_memory_pools(Interp *dest, Interp *source)
Does nothing.
void Parrot_destroy_memory_pools(PARROT_INTERP)
Does nothing.
gc_collect_runs
count.
malloc()
and returns it.
Panics if there is no memory available.
calloc()
and returns it.
Panics if there is no memory available.
realloc()
and returns it.
Panics if there is no memory available.
bufstart
for refcounting in GC.
size
has to be a multiple of the word size.
PObj_buflen
will be set to exactly the given size
.
See the comments and diagram in resources.c.This was never called anyway,
so it isn't implemented here.
*str
and returns it.
newsize
is the number of bytes memory required.
*str
and returns it.
size
is the number bytes of memory required.
SEE ALSO
config/auto/gc.pl, src/malloc.c, include/parrot/resources.h.