Stardew Engine
Loading...
Searching...
No Matches
ObjectPool.h File Reference
#include "IntTypes.h"
Include dependency graph for ObjectPool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ObjectPoolData
 16 byte aligned More...
 

Macros

#define OBJECT_POOL(a)   a*
 
#define NEW_OBJECT_POOL(a, size)   ((a*)InitObjectPool(sizeof(a),size))
 
#define ObjectPoolCapacity(pObjectPool)   ((((struct ObjectPoolData*)pObjectPool) - 1)->capacity)
 
#define OBJ_POOL_BOUNDS_CHECK(handle, rVal, pool)
 
#define OBJ_POOL_BOUNDS_CHECK_NO_RETURN(handle, pool)
 
#define ObjectPoolFreeArraySize(pObjectPool)   (((struct ObjectPoolData*)pObjectPool) - 1)->freeObjectsArraySize
 

Functions

void * InitObjectPool (int objectSize, int poolInitialSize)
 
void * GetObjectPoolIndex (void *pObjectPool, int *pOutIndex)
 returns the object pool, possibly resized. returns index of a free space in the pool through pOutIndex
 
void FreeObjectPoolIndex (void *pObjectPool, int indexToFree)
 
void * FreeObjectPool (void *pObjectPool)
 

Macro Definition Documentation

◆ NEW_OBJECT_POOL

#define NEW_OBJECT_POOL (   a,
  size 
)    ((a*)InitObjectPool(sizeof(a),size))

◆ OBJ_POOL_BOUNDS_CHECK

#define OBJ_POOL_BOUNDS_CHECK (   handle,
  rVal,
  pool 
)
Value:
{\
bool bBoundsValid = handle < ObjectPoolCapacity(pool) && handle >= 0;\
if(!bBoundsValid){\
printf("function '%s' invalid bounds handle %i", __FUNCTION__, handle);\
return rVal;\
}\
}
#define ObjectPoolCapacity(pObjectPool)
Definition ObjectPool.h:29

◆ OBJ_POOL_BOUNDS_CHECK_NO_RETURN

#define OBJ_POOL_BOUNDS_CHECK_NO_RETURN (   handle,
  pool 
)
Value:
{\
bool bBoundsValid = handle < ObjectPoolCapacity(pool) && handle >= 0;\
if(!bBoundsValid){\
printf("function '%s' invalid bounds handle %i", __FUNCTION__, handle);\
return;\
}\
}

◆ OBJECT_POOL

#define OBJECT_POOL (   a)    a*

◆ ObjectPoolCapacity

#define ObjectPoolCapacity (   pObjectPool)    ((((struct ObjectPoolData*)pObjectPool) - 1)->capacity)

◆ ObjectPoolFreeArraySize

#define ObjectPoolFreeArraySize (   pObjectPool)    (((struct ObjectPoolData*)pObjectPool) - 1)->freeObjectsArraySize

Function Documentation

◆ FreeObjectPool()

void * FreeObjectPool ( void *  pObjectPool)

◆ FreeObjectPoolIndex()

void FreeObjectPoolIndex ( void *  pObjectPool,
int  indexToFree 
)

◆ GetObjectPoolIndex()

void * GetObjectPoolIndex ( void *  pObjectPool,
int *  pOutIndex 
)

returns the object pool, possibly resized. returns index of a free space in the pool through pOutIndex

◆ InitObjectPool()

void * InitObjectPool ( int  objectSize,
int  poolInitialSize 
)