Logo Search packages:      
Sourcecode: maxdb-7.5.00 version File versions

void * LVCMem_BlockAllocator::Allocate ( SAPDB_ULong  BlockCount  )  [virtual]

Allocates contiguous memory for 'BlockCount' blocks of memory.

An implementation grants that a pointer returned will be an integral multiple of the system page size. The memory is not initialised. (void *)0 is returned on failure.

Parameters:
BlockCount [ in ] Number of blocks (NOT bytes!) to allocate.
Returns:
value pointer to the block allocated

Implements SAPDBMem_IBlockAllocator.

Definition at line 85 of file LVCMem_BlockAllocator.cpp.

References SAPDBMem_IBlockAllocator::Allocate(), GetBlockSize(), m_allocated, m_allocator, m_CountAlloc, m_CountBaseAlloc, m_defaultBlockCount, m_firstFree, m_limit, m_spinlock, and m_writeHeapLimitOpMsg.

{
#ifdef SAPDBMem_USE_SYSTEM_ALLOC
  void *p = malloc(BlockCount * GetBlockSize());
  return p;
#else
  RTESync_LockedScope lockedScope(m_spinlock);
  ++m_CountAlloc;
  if ((BlockCount == m_defaultBlockCount) && (0 != m_firstFree))
  {
    void* p = m_firstFree;
    m_firstFree = m_firstFree->m_next;
    return p;
  }
  if (m_allocated + BlockCount <= m_limit)
  {
    void* p = m_allocator.Allocate(BlockCount);
    if (0 != p)
    {
        ++m_CountBaseAlloc;
      m_writeHeapLimitOpMsg = true;
      m_allocated += BlockCount;
    }
    return p;
  }
  else
  {
    if (m_writeHeapLimitOpMsg)
    {
      Kernel_OpError errorMsg(csp3_no_more_memory, csp3_n_memory);
      errorMsg << "OMS_HEAP_LIMIT reached" << FlushLine;
      errorMsg << "Allocated : " << (m_allocated * GetBlockSize()) << FlushLine;
      errorMsg << "Required  : " << (BlockCount  * GetBlockSize()) << FlushLine;
      m_writeHeapLimitOpMsg = false;
    }
    return 0;
  }
#endif
}


Generated by  Doxygen 1.6.0   Back to index