#include <Obstack_T.h>
Inheritance diagram for ACE_Obstack_T:


Public Methods | |
| ACE_Obstack_T (size_t size=(4096 *sizeof(CHAR))-sizeof(ACE_Obchunk), ACE_Allocator *allocator_strategy=0) | |
| ~ACE_Obstack_T (void) | |
| int | 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. More... | |
| CHAR * | grow (CHAR c) |
| Inserting a new CHAR 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. More... | |
| void | grow_fast (CHAR c) |
| Inserting a new CHAR c into the current building block without freezing (null terminating) the block and without checking for out-of-bound error. More... | |
| CHAR * | freeze (void) |
| Freeze the current building block by null terminating it. Return the starting address of the current building block, 0 if error occurs. More... | |
| CHAR * | copy (const CHAR *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. More... | |
| size_t | length (void) const |
| Return the maximum length or size of a string that can be put into this Obstack. size = length * sizeof (CHAR). Deprecated : No need to use this function as you can put objects of arbitrary lengths into the obstack now. More... | |
| size_t | size (void) const |
| void | 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. More... | |
| void | release (void) |
| "Release" the entire stack of Obchunks, putting it back on the free list. More... | |
| void | dump (void) const |
| Dump the state of an object. More... | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. More... | |
Protected Methods | |
| ACE_Obchunk * | new_chunk (void) |
| void | unwind_i (void *obj) |
| Search through the list of Obchunks and release them. Helper funtion used by unwind. More... | |
Protected Attributes | |
| ACE_Allocator * | allocator_strategy_ |
| Pointer to the allocator used by this Obstack. More... | |
| size_t | size_ |
| Current size of the Obstack;. More... | |
| ACE_Obchunk * | head_ |
| Head of the Obchunk chain. More... | |
| ACE_Obchunk * | curr_ |
| Pointer to the current Obchunk. More... | |
|
||||||||||||||||
|
Definition at line 122 of file Obstack_T.cpp. References ACE_ALLOCATOR, ACE_TRACE, allocator_strategy_, curr_, head_, ACE_Allocator::instance, and new_chunk.
00124 : allocator_strategy_ (allocator_strategy), 00125 size_ (size) 00126 { 00127 ACE_TRACE ("ACE_Obstack_T<CHAR>::ACE_Obstack"); 00128 00129 if (this->allocator_strategy_ == 0) 00130 ACE_ALLOCATOR (this->allocator_strategy_, 00131 ACE_Allocator::instance ()); 00132 00133 this->head_ = this->new_chunk (); 00134 this->curr_ = this->head_; 00135 } |
|
||||||||||
|
Definition at line 138 of file Obstack_T.cpp. References ACE_TRACE, allocator_strategy_, ACE_Allocator::free, head_, and ACE_Obchunk::next_.
00139 {
00140 ACE_TRACE ("ACE_Obstack_T<CHAR>::~ACE_Obstack_T");
00141
00142 ACE_Obchunk *temp = this->head_;
00143
00144 while (temp != 0)
00145 {
00146 ACE_Obchunk *next = temp->next_;
00147 temp->next_ = 0;
00148 this->allocator_strategy_->free (temp);
00149 temp = next;
00150 }
00151 }
|
|
||||||||||||||||
|
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.
Definition at line 154 of file Obstack_T.cpp. References ACE_TRACE, ACE_Obchunk::cur_, curr_, freeze, ACE_OS_String::memcpy, and request.
|
|
||||||||||
|
Dump the state of an object.
Definition at line 21 of file Obstack_T.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.
00022 {
00023 ACE_TRACE ("ACE_Obstack_T<CHAR>::dump");
00024
00025 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00026 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("size_ = %d\n"), this->size_));
00027 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("head_ = %x\n"), this->head_));
00028 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("curr_ = %x\n"), this->curr_));
00029 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00030 }
|
|
||||||||||
|
Freeze the current building block by null terminating it. Return the starting address of the current building block, 0 if error occurs.
Definition at line 24 of file Obstack_T.i. References ACE_Obchunk::block_, ACE_Obchunk::cur_, and curr_. Referenced by copy.
|
|
||||||||||
|
Inserting a new CHAR 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.
Definition at line 89 of file Obstack_T.cpp. References ACE_TRACE, ACE_Obchunk::cur_, curr_, and request.
|
|
||||||||||
|
Inserting a new CHAR c into the current building block without freezing (null terminating) the block and without checking for out-of-bound error.
Definition at line 16 of file Obstack_T.i. References ACE_Obchunk::cur_, and curr_.
|
|
||||||||||
|
Return the maximum length or size of a string that can be put into this Obstack. size = length * sizeof (CHAR). Deprecated : No need to use this function as you can put objects of arbitrary lengths into the obstack now.
Definition at line 4 of file Obstack_T.i. References size_.
00005 {
00006 return this->size_ / sizeof (CHAR);
00007 }
|
|
||||||||||
|
Definition at line 106 of file Obstack_T.cpp. References ACE_NEW_MALLOC_RETURN, and ACE_TRACE. Referenced by ACE_Obstack_T, and request.
00107 {
00108 ACE_TRACE ("ACE_Obstack_T<CHAR>::new_chunk");
00109
00110 ACE_Obchunk *temp;
00111
00112 ACE_NEW_MALLOC_RETURN (temp,
00113 ACE_static_cast (ACE_Obchunk *,
00114 this->allocator_strategy_->malloc
00115 (sizeof (class ACE_Obchunk) + this->size_)),
00116 ACE_Obchunk (this->size_),
00117 0);
00118 return temp;
00119 }
|
|
||||||||||
|
"Release" the entire stack of Obchunks, putting it back on the free list.
Definition at line 198 of file Obstack_T.cpp. References ACE_TRACE, ACE_Obchunk::block_, ACE_Obchunk::contents_, ACE_Obchunk::cur_, curr_, and head_.
|
|
||||||||||
|
Request Obstack to prepare a block at least len long for building a new string. Return -1 if fail, 0 if success.
Definition at line 33 of file Obstack_T.cpp. References ACE_TRACE, ACE_Obchunk::block_, ACE_Obchunk::contents_, ACE_Obchunk::cur_, curr_, ACE_Obchunk::end_, ACE_OS_String::memcpy, new_chunk, ACE_Obchunk::next_, and size_.
00034 {
00035 ACE_TRACE ("ACE_Obstack_T<CHAR>::request");
00036
00037 // normalize the length.
00038 len *= sizeof (CHAR);
00039
00040 // Check to see if there's room for the requested length, including
00041 // any part of an existing string, if any.
00042 size_t resulting_len = (this->curr_->cur_ - this->curr_->block_) + len;
00043
00044 // Increase the length of the underlying chunks if the request made is
00045 // for bigger sized chunks.
00046 if (this->size_ < resulting_len)
00047 this->size_ = this->size_ << 1;
00048
00049 // We now know the request will fit; see if it can fit in the current
00050 // chunk or will need a new one.
00051 if (this->curr_->cur_ + len >= this->curr_->end_)
00052 {
00053 // Need a new chunk. Save the current one so the current string can be
00054 // copied to the new chunk.
00055 ACE_Obchunk *temp = this->curr_;
00056 if (this->curr_->next_ == 0)
00057 {
00058 // We must allocate new memory.
00059 ACE_Obchunk* tmp = this->new_chunk();
00060 if (!tmp)
00061 return -1;
00062 this->curr_->next_ = tmp;
00063 this->curr_ = this->curr_->next_;
00064 }
00065 else
00066 {
00067 // We can reuse previously allocated memory.
00068 this->curr_ = this->curr_->next_;
00069 this->curr_->block_ = this->curr_->cur_ = this->curr_->contents_;
00070 }
00071
00072 // Copy any initial characters to the new chunk.
00073 if (temp->cur_ != temp->block_)
00074 {
00075 size_t datasize = temp->cur_ - temp->block_;
00076 ACE_OS::memcpy (this->curr_->block_,
00077 temp->block_,
00078 datasize);
00079 this->curr_->cur_ = this->curr_->block_ + datasize;
00080 // Reset the old chunk.
00081 temp->cur_ = temp->block_;
00082 }
00083 }
00084
00085 return 0;
00086 }
|
|
||||||||||
|
Definition at line 10 of file Obstack_T.i. References size_.
00011 {
00012 return this->size_;
00013 }
|
|
||||||||||
|
"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.
Definition at line 169 of file Obstack_T.cpp. References ACE_Obchunk::block_, ACE_Obchunk::contents_, ACE_Obchunk::cur_, curr_, ACE_Obchunk::end_, and unwind_i.
|
|
||||||||||
|
Search through the list of Obchunks and release them. Helper funtion used by unwind.
Definition at line 179 of file Obstack_T.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_Obchunk::block_, ACE_Obchunk::contents_, ACE_Obchunk::cur_, curr_, ACE_Obchunk::end_, head_, LM_ERROR, and ACE_Obchunk::next_. Referenced by unwind.
00180 {
00181 ACE_Obchunk* curr;
00182
00183 curr = this->head_;
00184 while (curr != 0 && (curr->contents_ > obj || curr->end_ < obj))
00185 curr = curr->next_;
00186 if (curr)
00187 {
00188 this->curr_ = curr;
00189 this->curr_->block_ = this->curr_->cur_ = ACE_reinterpret_cast (char*,
00190 obj);
00191 }
00192 else if (obj != 0)
00193 ACE_ERROR ((LM_ERROR,
00194 ACE_LIB_TEXT ("Deletion of non-existent object.\n%a")));
00195 }
|
|
|||||
|
Declare the dynamic allocation hooks.
Definition at line 89 of file Obstack_T.h. |
|
|||||
|
Pointer to the allocator used by this Obstack.
Definition at line 99 of file Obstack_T.h. Referenced by ACE_Obstack_T, and ~ACE_Obstack_T. |
|
|||||
|
Pointer to the current Obchunk.
Definition at line 109 of file Obstack_T.h. Referenced by ACE_Obstack_T, copy, freeze, grow, grow_fast, release, request, unwind, and unwind_i. |
|
|||||
|
Head of the Obchunk chain.
Definition at line 106 of file Obstack_T.h. Referenced by ACE_Obstack_T, release, unwind_i, and ~ACE_Obstack_T. |
|
|||||
|
Current size of the Obstack;.
Definition at line 102 of file Obstack_T.h. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002