ACE
6.2.5
|
Define a simple "mark and release" memory allocation utility. More...
#include <Obstack_T.h>
Public Member Functions | |
ACE_Obstack_T (size_t size=(4096 *sizeof(ACE_CHAR_T))-sizeof(ACE_Obchunk), ACE_Allocator *allocator_strategy=0) | |
~ACE_Obstack_T (void) | |
int | request (size_t len) |
ACE_CHAR_T * | grow (ACE_CHAR_T c) |
void | grow_fast (ACE_CHAR_T c) |
ACE_CHAR_T * | freeze (void) |
ACE_CHAR_T * | copy (const ACE_CHAR_T *data, size_t len) |
size_t | size (void) const |
Return the maximum size. More... | |
void | unwind (void *obj) |
void | release (void) |
void | dump (void) const |
Dump the state of an object. More... | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. More... | |
Protected Member Functions | |
class ACE_Obchunk * | new_chunk (void) |
void | unwind_i (void *obj) |
Protected Attributes | |
ACE_Allocator * | allocator_strategy_ |
Pointer to the allocator used by this Obstack. More... | |
size_t | size_ |
Current size of the Obstack;. More... | |
class ACE_Obchunk * | head_ |
Head of the Obchunk chain. More... | |
class ACE_Obchunk * | curr_ |
Pointer to the current Obchunk. More... | |
Define a simple "mark and release" memory allocation utility.
The implementation is similar to the GNU obstack utility, which is used extensively in the GCC compiler.
ACE_Obstack_T< ACE_CHAR_T >::ACE_Obstack_T | ( | size_t | size = (4096 * sizeof (ACE_CHAR_T)) - sizeof (ACE_Obchunk) , |
ACE_Allocator * | allocator_strategy = 0 |
||
) |
ACE_Obstack_T< ACE_CHAR_T >::~ACE_Obstack_T | ( | void | ) |
ACE_CHAR_T * ACE_Obstack_T< ACE_CHAR_T >::copy | ( | const ACE_CHAR_T * | data, |
size_t | len | ||
) |
Copy the data into the current Obchunk and freeze the current block. Return the starting address of the current building block, 0 if error occurs. len specify the string length, not the actually data size.
void ACE_Obstack_T< ACE_CHAR_T >::dump | ( | void | ) | const |
Dump the state of an object.
ACE_CHAR_T * ACE_Obstack_T< ACE_CHAR_T >::freeze | ( | void | ) |
Freeze the current building block by null terminating it. Return the starting address of the current building block, 0 if error occurs.
ACE_CHAR_T * ACE_Obstack_T< ACE_CHAR_T >::grow | ( | ACE_CHAR_T | c | ) |
Inserting a new ACE_CHAR_T c into the current building block without freezing (null terminating) the block. This function will create new chunk by checking the boundary of current Obchunk. Return the location c gets inserted to, or 0 if error.
void ACE_Obstack_T< ACE_CHAR_T >::grow_fast | ( | ACE_CHAR_T | c | ) |
Inserting a new ACE_CHAR_T c into the current building block without freezing (null terminating) the block and without checking for out-of-bound error.
|
protected |
void ACE_Obstack_T< ACE_CHAR_T >::release | ( | void | ) |
"Release" the entire stack of Obchunks, putting it back on the free list.
int ACE_Obstack_T< ACE_CHAR_T >::request | ( | size_t | len | ) |
Request Obstack to prepare a block at least len long for building a new string. Return -1 if fail, 0 if success.
|
inline |
Return the maximum size.
void ACE_Obstack_T< ACE_CHAR_T >::unwind | ( | void * | obj | ) |
"Unwind" the stack. If obj is a null pointer, everything allocated in the stack is released. Otherwise, obj must be an address of an object allocated in the stack. In this case, obj is released along with everthing allocated in the Obstack since obj.
|
protected |
Search through the list of Obchunks and release them. Helper funtion used by unwind.
ACE_Obstack_T< ACE_CHAR_T >::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
|
protected |
Pointer to the allocator used by this Obstack.
|
protected |
Pointer to the current Obchunk.
|
protected |
Head of the Obchunk chain.
|
protected |
Current size of the Obstack;.