FRAMEWORK/MemChain.hpp
//---------------------------------------------------------------------------
// Does nothing if the block is full (4GB)
// Tries to resize this block inplace 
// Check BlkSize/BlkFullSize afterwards to confirm success
//
Does nothing if the block is full (4GB)
Tries to resize this block inplace
Check BlkSize/BlkFullSize afterwards to confirm success
Does nothing if the block is full ( 4GB ) Tries to resize this block inplace Check BlkSize / BlkFullSize afterwards to confirm success
TSlf* Resize(SIZE_T BlkSize, bool CanReloc=false)        
{
 if(BlkSize > this->Full)     
  {
   SIZE_T FullSize = 0; 
   SIZE_T DataSize = 0; 
   TSlf* This = (TSlf*)Alloca::Realloc(this, BlkSize, this->Size, &DataSize, &FullSize);   
   if(!This)  
    {
     if(!CanReloc)return nullptr;   
     This = TSlf::Create(BlkSize);      
     if(!This)return nullptr; 
     CopyMem(This->DataPtr(), this->DataPtr(), this->DataLen());
     this->BlkInsBefore(This);
     this->Delete();
     return This;
    }
    else if(This != (TSlf*)this)    
     {
      if(This->Next)This->Next->Prev = This;  
      if(This->Prev)This->Prev->Next = This;
       else SetAsFirst(This);     
     } 
   this->Size = DataSize;
   this->Full = FullSize;  
   return This;
  }
 if(BlkSize < sizeof(TSlf))BlkSize = sizeof(TSlf);     
 if(BlkSize != this->Size)
  {
   Alloca::Resize(this, BlkSize, this->Full); 
   this->Size = BlkSize;   
  }
 return static_cast<TSlf*>(this);
}
TSlf * Resize ( SIZE_T BlkSize , bool CanReloc = false ) { if ( BlkSize > this -> Full ) { SIZE_T FullSize = 0 ; SIZE_T DataSize = 0 ; TSlf * This = ( TSlf * ) Alloca :: Realloc ( this , BlkSize , this -> Size , & DataSize , & FullSize ) ; if ( ! This ) { if ( ! CanReloc ) return nullptr ; This = TSlf :: Create ( BlkSize ) ; if ( ! This ) return nullptr ; CopyMem ( This -> DataPtr ( ) , this -> DataPtr ( ) , this -> DataLen ( ) ) ; this -> BlkInsBefore ( This ) ; this -> Delete ( ) ; return This ; } else if ( This != ( TSlf * ) this ) { if ( This -> Next ) This -> Next -> Prev = This ; if ( This -> Prev ) This -> Prev -> Next = This ; else SetAsFirst ( This ) ; } this -> Size = DataSize ; this -> Full = FullSize ; return This ; } if ( BlkSize < sizeof ( TSlf ) ) BlkSize = sizeof ( TSlf ) ; if ( BlkSize != this -> Size ) { Alloca :: Resize ( this , BlkSize , this -> Full ) ; this -> Size = BlkSize ; } return static_cast < TSlf * > ( this ) ; }
Does nothing if the block is full (4GB)
Tries to resize this block inplace
Check BlkSize/BlkFullSize afterwards to confirm success
Does nothing if the block is full ( 4GB ) Tries to resize this block inplace Check BlkSize / BlkFullSize afterwards to confirm success
// Do not use this with PageChain // Shrink or enlarge the committed block // But no releasing the block // Try again // Reallocated to a different location // Update its pointers in LinkedList // This was the first block // First page must be always present    // NOTE: Size is not consider any derived classes by this is not important here // New size of this block