NAME
OTC_Arena -
A memory allocator which concatenates requests into blocks.
SYNOPSIS
#include <OTC/memory/arena.hh>
class OTC_Arena
{
public:
static os_typespec* get_os_typespec();
OTC_Arena(size_t theAlign=OTC_Alignment::ofDouble());
inline OTC_Arena(
size_t theBlockSize,
size_t theSlop,
size_t theAlign=OTC_Alignment::ofDouble(
);
~OTC_Arena();
void* allocate(size_t theSize);
};
CLASS TYPE
Concrete
DESCRIPTION
OTC_Arena is a memory allocator which obtains blocks
of memory using operator new() and then parcels the
memory out in pieces. All memory allocated must be freed
at the same time.
CONSTRUCTION
OTC_Arena(size_t theAlign=OTC_Alignment::ofDouble());
Initialises the class. The block size used
for allocating memory will be 2040 bytes
unless overridden by the environment
variable OTCLIB_ARENABLOCKSIZE. When the
amount of free space in a block falls
below 16 bytes, the class will stop
trying to allocate memory from that block.
The slop value can be overridden by
setting the environment variable
OTCLIB_ARENASLOPSIZE. Memory returned
will be aligned according to theAlign.
The default is to align memory to that
required by the type double. If
theAlign is 0 an exception is raised.
inline OTC_Arena(
size_t theBlockSize,
size_t theSlop,
size_t theAlign=OTC_Alignment::ofDouble(
);
Initialises the class. theBlockSize
should be the minimum amount of memory
allocated from the free store. When the
amount of free space in a block decreases
below theSlop, the class stops trying to
allocate from that block. Memory returned
will be aligned according to theAlign.
The default is to align memory to that
required by the type double.
If theAlign is 0 an exception is
raised.
DESTRUCTION
~OTC_Arena();
Returns all memory to the free store.
ALLOCATION
void* allocate(size_t theSize);
Returns a piece of memory of size
theSize.
NOTES
If a request for memory greater than the block size is
requested, it will be allocated directly from the free
store.
The default block size is 2040. A weird value calculated
by looking at size of blocks allocated by GNU malloc and
BSD malloc. Sun malloc used first fit, so the size doesn't
matter too much when using it.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED