|
@@ -116,26 +116,12 @@ struct Pool {
|
|
|
FORCEINLINE void *operator new(size_t size, size_t index)
|
|
|
{
|
|
|
return Tpool->GetNew(size, index);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Deletes item with given index.
|
|
|
* @param p Titem memory to release
|
|
|
* @param index index of item
|
|
|
* @note never use this! Only for internal use
|
|
|
* (called automatically when constructor of Titem uses throw())
|
|
|
*/
|
|
|
FORCEINLINE void operator delete(void *p, size_t index)
|
|
|
{
|
|
|
assert(p == Tpool->Get(index));
|
|
|
Tpool->FreeItem(index);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Allocates space for new Titem at given memory address
|
|
|
* @param size size of Titem
|
|
|
* @param ptr where are we allocating the item?
|
|
|
* @return pointer to allocated memory (== ptr)
|
|
|
* @note use of this is strongly discouraged
|
|
|
* @pre the memory must not be allocated in the Pool!
|
|
@@ -151,27 +137,12 @@ struct Pool {
|
|
|
* instead to make sure destructor is called and no memory leaks. */
|
|
|
assert(ptr != Tpool->data[i]);
|
|
|
}
|
|
|
return ptr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Deletes item that was allocated by the function above
|
|
|
* @param p Titem memory to release
|
|
|
* @param ptr parameter given to operator new
|
|
|
* @note never use this! Only for internal use
|
|
|
* (called automatically when constructor of Titem uses throw())
|
|
|
*/
|
|
|
FORCEINLINE void operator delete(void *p, void *ptr)
|
|
|
{
|
|
|
assert(p == ptr);
|
|
|
for (size_t i = 0; i < Tpool->first_unused; i++) {
|
|
|
assert(ptr != Tpool->data[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/** Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() */
|
|
|
|
|
|
/**
|
|
|
* Tests whether we can allocate 'n' items
|
|
|
* @param n number of items we want to allocate
|