37 #if defined (BT_HAS_ALIGNED_ALLOCATOR)    41         return _aligned_malloc(size, (
size_t)alignment);
    48 #elif defined(__CELLOS_LV2__)    53         return memalign(alignment, 
size);
    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   109 static int allocations_id[10241024];
   110 static int allocations_bytes[10241024];
   111 static int mynumallocs = 0;
   114 int btDumpMemoryLeaks()
   118         for (
int i=0;i<mynumallocs;i++)
   120                 printf(
"Error: leaked memory of allocation #%d (%d bytes)\n", allocations_id[i], allocations_bytes[i]);
   121                 totalLeak+=allocations_bytes[i];
   125                 printf(
"Error: memory leaks: %d allocations were not freed and leaked together %d bytes\n",mynumallocs,totalLeak);
   132 struct btDebugPtrMagic
   148                 printf(
"Whaat? size==0");
   151         static int allocId = 0;
   170 int sz4prt = 4*
sizeof(
void *);
   178          p.cptr-=
sizeof(
void*);
   179          *p.vptrptr = (
void*)real;
   180          p.cptr-=
sizeof(
void*);
   182          p.cptr-=
sizeof(
void*);
   185          allocations_id[mynumallocs] = allocId;
   186          allocations_bytes[mynumallocs] = 
size;
   190    ret = (
void *)(real);
   193  printf(
"allocation %d at address %x, from %s,line %d, size %d (total allocated = %d)\n",allocId,real, filename,line,
size,
gTotalBytesAlignedAllocs);
   196  int* ptr = (
int*)ret;
   211          p.cptr-=
sizeof(
void*);
   213          p.cptr-=
sizeof(
void*);
   215          p.cptr-=
sizeof(
void*);
   216          int allocId = *p.iptr;
   220          for (
int i=0;i<mynumallocs;i++)
   222                  if ( allocations_id[i] == allocId)
   224                          allocations_id[i] = allocations_id[mynumallocs-1];
   225                          allocations_bytes[i] = allocations_bytes[mynumallocs-1];
   236         printf(
"free %d at address %x, from %s,line %d, size %d (total remain = %d in %d non-freed allocations)\n",allocId,real, filename,line,size, 
gTotalBytesAlignedAllocs, diff);
   245 #else //BT_DEBUG_MEMORY_ALLOCATIONS   268 #endif //BT_DEBUG_MEMORY_ALLOCATIONS static void * btAlignedAllocDefault(size_t size, int alignment)
static btFreeFunc * sFreeFunc
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btAlignedAllocFunc * sAlignedAllocFunc
int gTotalBytesAlignedAllocs
void( btFreeFunc)(void *memblock)
void *( btAlignedAllocFunc)(size_t size, int alignment)
static btAlignedFreeFunc * sAlignedFreeFunc
void( btAlignedFreeFunc)(void *memblock)
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 *( btAllocFunc)(size_t size)
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)