Logo Search packages:      
Sourcecode: blender version File versions  Download package

void * btGenericMemoryPool::allocate ( size_t  size_bytes  ) 

Allocates memory in pool.

Parameters:
size_bytes size in bytes of the buffer
size_bytes size in bytes of the buffer

Definition at line 119 of file btGenericPoolAllocator.cpp.

References allocate_from_free_nodes().

Referenced by btGenericPoolAllocator::allocate().

{

      size_t module = size_bytes%m_element_size;
      size_t element_count = size_bytes/m_element_size;
      if(module>0) element_count++;

      size_t alloc_pos = allocate_from_free_nodes(element_count);
      // a free node is found
      if(alloc_pos != BT_UINT_MAX)
      {
            return get_element_data(alloc_pos);
      }
      // allocate directly on pool
      alloc_pos = allocate_from_pool(element_count);

      if(alloc_pos == BT_UINT_MAX) return NULL; // not space
      return get_element_data(alloc_pos);
}


Generated by  Doxygen 1.6.0   Back to index