37 #if defined (BT_HAS_ALIGNED_ALLOCATOR)
41 return _aligned_malloc(size, (
size_t)alignment);
48 #elif defined(__CELLOS_LV2__)
70 real = (
char *)
sAllocFunc(size +
sizeof(
void *) + (alignment-1));
73 *((
void **)(ret)-1) = (
void *)(real);
85 real = *((
void **)(ptr)-1);
107 #ifdef BT_DEBUG_MEMORY_ALLOCATIONS
120 real = (
char *)
sAllocFunc(size + 2*
sizeof(
void *) + (alignment-1));
123 *((
void **)(ret)-1) = (
void *)(real);
124 *((
int*)(ret)-2) = size;
127 ret = (
void *)(real);
130 printf(
"allocation#%d at address %x, from %s,line %d, size %d\n",
gNumAlignedAllocs,real, filename,line,size);
132 int* ptr = (
int*)ret;
144 real = *((
void **)(ptr)-1);
145 int size = *((
int*)(ptr)-2);
148 printf(
"free #%d at address %x, from %s,line %d, size %d\n",
gNumAlignedFree,real, filename,line,size);
153 printf(
"NULL ptr\n");
157 #else //BT_DEBUG_MEMORY_ALLOCATIONS
180 #endif //BT_DEBUG_MEMORY_ALLOCATIONS
void *( btAllocFunc)(size_t size)
void( btFreeFunc)(void *memblock)
static void * btAlignedAllocDefault(size_t size, int alignment)
static btFreeFunc * sFreeFunc
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btAlignedAllocFunc * sAlignedAllocFunc
int gTotalBytesAlignedAllocs
static btAlignedFreeFunc * sAlignedFreeFunc
static void btAlignedFreeDefault(void *ptr)
static void btFreeDefault(void *ptr)
void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc)
If the developer has already an custom aligned allocator, then btAlignedAllocSetCustomAligned can be ...
void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc)
The developer can let all Bullet memory allocations go through a custom memory allocator, using btAlignedAllocSetCustom.
void *( btAlignedAllocFunc)(size_t size, int alignment)
void( btAlignedFreeFunc)(void *memblock)
void btAlignedFreeInternal(void *ptr)
void * btAlignedAllocInternal(size_t size, int alignment)
we probably replace this with our own aligned memory allocator so we replace _aligned_malloc and _ali...
T * btAlignPointer(T *unalignedPtr, size_t alignment)
align a pointer to the provided alignment, upwards
static btAllocFunc * sAllocFunc
static void * btAllocDefault(size_t size)