#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);
};
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.
OTC_Arena(size_t theAlign=OTC_Alignment::ofDouble());
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(
);
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.
~OTC_Arena();
void* allocate(size_t theSize);
theSize
.
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.