The Support Kit Table of Contents | The Support Kit Index |
Derived from: none
Declared in: be/support/BlockCache.h
Library: libbe.so
The BBlockCache class pre-allocates a pool of fixed-length blocks of memory. You call Get() to retrieve a block of memory from the pool, and Save() to return it. BBlockCache objects are useful in applications that frequently allocate and deallocate fixed-sized objects, and in the implementations of a class' new and delete operators.
|
Creates a new memory block pool, allocating memory for count blocks, each controlling size bytes of memory. type is either:
|
Frees any unused memory in the object's block pool. Memory that was retrieved through Get() (and that hasn't been returned through Save()) is not deallocated.
|
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().
|
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.
The Support Kit Table of Contents | The Support Kit Index |
Copyright © 2000 Be, Inc. All rights reserved..