| Class Overview |
BBlockCache(size_t count,
size_t size,
uint32 type);
Creates a new memory block pool, allocating memory for count
blocks, each
controlling size
bytes of memory. type
is either:
Constant | Description |
---|---|
| Memory is managed through
|
| Memory is managed through
|
void* Get(size_t size);
Retrieves a block of memory of the given
size
and returns it directly. If
size
is the same as the
size
argument you passed to the constructor, the
memory returned will be taken from the object's cache. Otherwise, it's
allocated using either new
or
malloc()
as requested in the constructor. When
you're done with the memory, you can either deallocate it yourself, or
return it to the BBlockCache
object by calling
Save()
.
void Save(void* pointer,
size_t size);
Returns, to the BBlockCache
object, size
bytes of memory pointed to by
pointer
. If the memory was taken from the object's pool, the memory is
returned to the pool. Otherwise, it's deallocated. In either case, the
caller is freed of responsibility for deallocating the memory.