Skip to content

Commit

Permalink
remove modification of nbytes += 1
Browse files Browse the repository at this point in the history
  • Loading branch information
smithAchang committed Sep 26, 2023
1 parent cca031f commit 34850b6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ACE/ace/Malloc_T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,10 @@ ACE_Cascaded_Multi_Size_Based_Allocator<ACE_LOCK>::ACE_Cascaded_Multi_Size_Based

comb_alloc_ptr tmp;
// If ACE_NEW fails, the hierarchy_ will be reconstructed when malloc API is called.
ACE_NEW (tmp, comb_alloc_type (this->initial_n_chunks_, this->initial_chunk_size_ + sizeof(ACE_UINT8)));
// Notice: need one octet to record hierarchy pos
ACE_NEW (tmp, comb_alloc_type (this->initial_n_chunks_,
this->initial_chunk_size_ + sizeof(ACE_UINT8))
);

this->hierarchy_.push_back (tmp);
}
Expand All @@ -409,9 +412,6 @@ void* ACE_Cascaded_Multi_Size_Based_Allocator<ACE_LOCK>::malloc (size_t nbytes)
// Will be assigned by lately Binary Search process.
size_t chunk_size;

// Need one octet to record hierarchy pos
nbytes += sizeof (ACE_UINT8);

// Use Binary Search to find minimal pos that value is bigger than nbytes.
size_t m = 0;
size_t l = 0;
Expand Down Expand Up @@ -467,6 +467,7 @@ void* ACE_Cascaded_Multi_Size_Based_Allocator<ACE_LOCK>::malloc (size_t nbytes)

const size_t reinitial_n_chunks = this->initial_n_chunks_ >> m;
comb_alloc_ptr newly_alloc;
// Notice: need one octet to record hierarchy pos
ACE_NEW_RETURN (newly_alloc,
comb_alloc_type (reinitial_n_chunks > this->min_initial_n_chunks_ ? reinitial_n_chunks : this->min_initial_n_chunks_,
chunk_size + sizeof(ACE_UINT8)),
Expand Down

0 comments on commit 34850b6

Please sign in to comment.