summaryrefslogtreecommitdiff
path: root/ace/Malloc_T.cpp
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1999-08-04 02:39:12 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1999-08-04 02:39:12 +0000
commit46a39dd4cd67f4eaa047bfb45acdbc97540a6530 (patch)
tree987ed4a510d9086983d2a107dc4d81e64a589a81 /ace/Malloc_T.cpp
parentc81d86d52e45aa32c5737d549f44e2ae212898b9 (diff)
downloadATCD-46a39dd4cd67f4eaa047bfb45acdbc97540a6530.tar.gz
ChangeLogTag:Tue Aug 3 18:50:02 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
Diffstat (limited to 'ace/Malloc_T.cpp')
-rw-r--r--ace/Malloc_T.cpp94
1 files changed, 47 insertions, 47 deletions
diff --git a/ace/Malloc_T.cpp b/ace/Malloc_T.cpp
index 3f760050910..1638c1810b4 100644
--- a/ace/Malloc_T.cpp
+++ b/ace/Malloc_T.cpp
@@ -103,16 +103,16 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::print_stats (void) const
ACE_DEBUG ((LM_DEBUG,
ASYS_TEXT ("(%P|%t) contents of freelist:\n")));
- for (ACE_Malloc_Header *currp = ACE_POINTER_CAST (this->cb_ptr_->freep_->s_.next_block_);
+ for (ACE_Malloc_Header *currp = this->cb_ptr_->freep_->s_.next_block_;
;
- currp = ACE_POINTER_CAST (currp->s_.next_block_))
+ currp = currp->s_.next_block_)
{
ACE_DEBUG ((LM_DEBUG,
ASYS_TEXT ("(%P|%t) ptr = %u, ACE_Malloc_Header units = %d, byte units = %d\n"),
currp,
currp->s_.size_,
currp->s_.size_ * sizeof (ACE_Malloc_Header)));
- if (currp == ACE_POINTER_CAST (this->cb_ptr_->freep_))
+ if (currp == this->cb_ptr_->freep_)
break;
}
}
@@ -167,8 +167,8 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::open (void)
#if defined (ACE_HAS_POSITION_INDEPENDENT_MALLOC)
// Initialize the freelist pointer to point to the dummy
// <ACE_Malloc_Header>.
- new ((void *) &this->cb_ptr_->freep_) ACE_Malloc_Header::HEADER_PTR (&this->cb_ptr_->base_);
- new ((void *) &this->cb_ptr_->name_head_) ACE_Based_Pointer<ACE_Name_Node>;
+ new ((void *) &this->cb_ptr_->freep_) ACE_MALLOC_HEADER_PTR (&this->cb_ptr_->base_);
+ new ((void *) &this->cb_ptr_->name_head_) ACE_NAME_NODE_PTR;
#else
// Initialize the freelist pointer to point to the dummy
// <ACE_Malloc_Header>.
@@ -180,14 +180,14 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::open (void)
// Initialize the dummy <ACE_Malloc_Header> to point to itself.
this->cb_ptr_->freep_->s_.size_ = 0;
- this->cb_ptr_->freep_->s_.next_block_ = ACE_POINTER_CAST (this->cb_ptr_->freep_);
+ this->cb_ptr_->freep_->s_.next_block_ = this->cb_ptr_->freep_;
if (rounded_bytes > (sizeof *this->cb_ptr_ + sizeof (ACE_Malloc_Header)))
{
// If we've got any extra space at the end of the control
// block, then skip past the dummy ACE_Malloc_Header to
// point at the first free block.
- ACE_Malloc_Header *p = ACE_POINTER_CAST (this->cb_ptr_->freep_) + 1;
+ ACE_Malloc_Header *p = ((ACE_Malloc_Header *) (this->cb_ptr_->freep_)) + 1;
// Why aC++ in 64-bit mode can't grok this, I have no
// idea... but it ends up with an extra bit set which makes
@@ -247,7 +247,8 @@ template <ACE_MEM_POOL_1, class ACE_LOCK>
ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Malloc (LPCTSTR pool_name,
LPCTSTR lock_name,
const void *options)
- : memory_pool_ (pool_name, (const ACE_MEM_POOL_OPTIONS *) options),
+ : memory_pool_ (pool_name,
+ (const ACE_MEM_POOL_OPTIONS *) options),
lock_ (lock_name)
{
ACE_TRACE ("ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Malloc");
@@ -299,25 +300,25 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_malloc (size_t nbytes)
// Round up request to a multiple of the ACE_Malloc_Header size.
size_t nunits =
- (nbytes + sizeof (ACE_Malloc_Header) - 1) / sizeof (ACE_Malloc_Header)
+ (nbytes + sizeof (ACE_Malloc_Header) - 1) / sizeof (ACE_Malloc_Header)
+ 1; // Add one for the <ACE_Malloc_Header> itself.
// Begin the search starting at the place in the freelist where the
// last block was found.
- ACE_Malloc_Header *prevp = ACE_POINTER_CAST (this->cb_ptr_->freep_);
- ACE_Malloc_Header *currp = ACE_POINTER_CAST (prevp->s_.next_block_);
+ ACE_Malloc_Header *prevp = this->cb_ptr_->freep_;
+ ACE_Malloc_Header *currp = prevp->s_.next_block_;
// Search the freelist to locate a block of the appropriate size.
for (int i = 0;
- ; i++, prevp = currp, currp = ACE_POINTER_CAST (currp->s_.next_block_))
+ ; i++, prevp = currp, currp = currp->s_.next_block_)
{
if (currp->s_.size_ >= nunits) // Big enough
{
AMS (++this->cb_ptr_->malloc_stats_.ninuse_);
if (currp->s_.size_ == nunits)
// Exact size, just update the pointers.
- prevp->s_.next_block_ = ACE_POINTER_CAST (currp->s_.next_block_);
+ prevp->s_.next_block_ = currp->s_.next_block_;
else
{
// Remaining chunk is larger than requested block, so
@@ -332,7 +333,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_malloc (size_t nbytes)
// Skip over the ACE_Malloc_Header when returning pointer.
return currp + 1;
}
- else if (currp == ACE_POINTER_CAST (this->cb_ptr_->freep_))
+ else if (currp == this->cb_ptr_->freep_)
{
// We've wrapped around freelist without finding a block.
// Therefore, we need to ask the memory pool for a new chunk
@@ -357,7 +358,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_malloc (size_t nbytes)
// free list. Skip over the ACE_Malloc_Header when
// returning pointer.
this->shared_free (currp + 1);
- currp = ACE_POINTER_CAST (this->cb_ptr_->freep_);
+ currp = this->cb_ptr_->freep_;
}
else
ACE_ERROR_RETURN ((LM_ERROR,
@@ -405,38 +406,38 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_free (void *ap)
return;
// Adjust AP to point to the block ACE_Malloc_Header
- ACE_Malloc_Header *blockp = (ACE_Malloc_Header *) ap - 1;
- ACE_Malloc_Header *currp = ACE_POINTER_CAST (this->cb_ptr_->freep_);
+ ACE_Malloc_Header *blockp = ((ACE_Malloc_Header *) ap) - 1;
+ ACE_Malloc_Header *currp = this->cb_ptr_->freep_;
// Search until we find the location where the blocks belongs. Note
// that addresses are kept in sorted order.
for (;
- blockp <= currp || blockp >= ACE_POINTER_CAST (currp->s_.next_block_);
- currp = ACE_POINTER_CAST (currp->s_.next_block_))
+ blockp <= currp || blockp >= currp->s_.next_block_;
+ currp = currp->s_.next_block_)
{
- if (currp >= ACE_POINTER_CAST (currp->s_.next_block_)
- && (blockp > currp || blockp < ACE_POINTER_CAST (currp->s_.next_block_)))
+ if (currp >= currp->s_.next_block_
+ && (blockp > currp || blockp < currp->s_.next_block_))
// Freed block at the start or the end of the memory pool.
break;
}
// Join to upper neighbor.
- if (blockp + blockp->s_.size_ == ACE_POINTER_CAST (currp->s_.next_block_))
+ if ((blockp + blockp->s_.size_) == currp->s_.next_block_)
{
AMS (--this->cb_ptr_->malloc_stats_.nblocks_);
blockp->s_.size_ += currp->s_.next_block_->s_.size_;
- blockp->s_.next_block_ = ACE_POINTER_CAST (currp->s_.next_block_->s_.next_block_);
+ blockp->s_.next_block_ = currp->s_.next_block_->s_.next_block_;
}
else
- blockp->s_.next_block_ = ACE_POINTER_CAST (currp->s_.next_block_);
+ blockp->s_.next_block_ = currp->s_.next_block_;
// Join to lower neighbor.
- if (currp + currp->s_.size_ == blockp)
+ if ((currp + currp->s_.size_) == blockp)
{
AMS (--this->cb_ptr_->malloc_stats_.nblocks_);
currp->s_.size_ += blockp->s_.size_;
- currp->s_.next_block_ = ACE_POINTER_CAST (blockp->s_.next_block_);
+ currp->s_.next_block_ = blockp->s_.next_block_;
}
else
currp->s_.next_block_ = blockp;
@@ -455,9 +456,9 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_find (const char *name)
if (this->cb_ptr_ == 0)
return 0;
- for (ACE_Name_Node *node = ACE_POINTER_CAST (this->cb_ptr_->name_head_);
+ for (ACE_Name_Node *node = this->cb_ptr_->name_head_;
node != 0;
- node = ACE_POINTER_CAST (node->next_))
+ node = node->next_)
if (ACE_OS::strcmp (node->name (),
name) == 0)
return node;
@@ -488,7 +489,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::shared_bind (const char *name,
name_ptr,
ACE_reinterpret_cast (char *,
pointer),
- ACE_POINTER_CAST (this->cb_ptr_->name_head_));
+ this->cb_ptr_->name_head_);
this->cb_ptr_->name_head_ = result;
return 0;
}
@@ -507,8 +508,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::trybind (const char *name,
else
{
// Found it, so return a copy of the current entry.
- pointer = ACE_reinterpret_cast (void *,
- ACE_POINTER_CAST (node->pointer_));
+ pointer = (char *) node->pointer_;
return 1;
}
}
@@ -546,8 +546,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::find (const char *name,
return -1;
else
{
- pointer = ACE_reinterpret_cast (void *,
- ACE_POINTER_CAST (node->pointer_));
+ pointer = (char *) node->pointer_;
return 0;
}
}
@@ -574,9 +573,9 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::avail_chunks (size_t size) const
// Avoid dividing by 0...
size = size == 0 ? 1 : size;
- for (ACE_Malloc_Header *currp = ACE_POINTER_CAST (this->cb_ptr_->freep_->s_.next_block_);
- currp != ACE_POINTER_CAST (this->cb_ptr_->freep_);
- currp = ACE_POINTER_CAST (currp->s_.next_block_))
+ for (ACE_Malloc_Header *currp = this->cb_ptr_->freep_->s_.next_block_;
+ currp != this->cb_ptr_->freep_;
+ currp = currp->s_.next_block_)
// Calculate how many will fit in this block.
if (currp->s_.size_ * sizeof (ACE_Malloc_Header) >= size)
count += currp->s_.size_ * sizeof (ACE_Malloc_Header) / size;
@@ -604,18 +603,18 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::unbind (const char *name, void *&pointer)
ACE_Name_Node *prev = 0;
- for (ACE_Name_Node *curr = ACE_POINTER_CAST (this->cb_ptr_->name_head_);
+ for (ACE_Name_Node *curr = this->cb_ptr_->name_head_;
curr != 0;
- curr = ACE_POINTER_CAST (curr->next_))
+ curr = curr->next_)
{
if (ACE_OS::strcmp (curr->name (), name) == 0)
{
- pointer = ACE_POINTER_CAST (curr->pointer_);
+ pointer = (char *) curr->pointer_;
if (prev == 0)
- this->cb_ptr_->name_head_ = ACE_POINTER_CAST (curr->next_);
+ this->cb_ptr_->name_head_ = curr->next_;
else
- prev->next_ = ACE_POINTER_CAST (curr->next_);
+ prev->next_ = curr->next_;
// This will free up both the node and the name due to our
// clever trick in <bind>!
@@ -664,7 +663,7 @@ ACE_Malloc_Iterator<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Malloc_Iterator (ACE_Malloc<A
// @@ Doug, this looks like trouble...
ACE_Name_Node temp;
this->curr_ = &temp;
- this->curr_->next_ = ACE_POINTER_CAST (malloc_.cb_ptr_->name_head_);
+ this->curr_->next_ = malloc_.cb_ptr_->name_head_;
this->advance ();
}
@@ -683,7 +682,7 @@ ACE_Malloc_Iterator<ACE_MEM_POOL_2, ACE_LOCK>::next (void *&next_entry,
if (this->curr_ != 0)
{
- next_entry = ACE_POINTER_CAST (this->curr_->pointer_);
+ next_entry = (char *) this->curr_->pointer_;
name = this->curr_->name ();
return 1;
}
@@ -698,7 +697,7 @@ ACE_Malloc_Iterator<ACE_MEM_POOL_2, ACE_LOCK>::next (void *&next_entry)
if (this->curr_ != 0)
{
- next_entry = ACE_POINTER_CAST (this->curr_->pointer_);
+ next_entry = this->curr_->pointer_;
return 1;
}
else
@@ -718,14 +717,15 @@ ACE_Malloc_Iterator<ACE_MEM_POOL_2, ACE_LOCK>::advance (void)
{
ACE_TRACE ("ACE_Malloc_Iterator<ACE_MEM_POOL_2, ACE_LOCK>::advance");
- this->curr_ = ACE_POINTER_CAST (this->curr_->next_);
+ this->curr_ = this->curr_->next_;
if (this->name_ == 0)
return this->curr_ != 0;
while (this->curr_ != 0
- && ACE_OS::strcmp (this->name_, this->curr_->name ()) != 0)
- this->curr_ = ACE_POINTER_CAST (this->curr_->next_);
+ && ACE_OS::strcmp (this->name_,
+ this->curr_->name ()) != 0)
+ this->curr_ = this->curr_->next_;
return this->curr_ != 0;
}