Added address to debug memory allocator
Renamed 'free' in 'freeMemory' to avoid name clashes with some Microsoft debugging tools.
This commit is contained in:
@@ -100,7 +100,7 @@ public:
|
||||
*/
|
||||
void * allocate(size_t size_bytes);
|
||||
|
||||
bool free(void * pointer);
|
||||
bool freeMemory(void * pointer);
|
||||
};
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
*/
|
||||
void * allocate(size_t size_bytes);
|
||||
|
||||
bool free(void * pointer);
|
||||
bool freeMemory(void * pointer);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ void * btGenericMemoryPool::allocate(size_t size_bytes)
|
||||
return get_element_data(alloc_pos);
|
||||
}
|
||||
|
||||
bool btGenericMemoryPool::free(void * pointer)
|
||||
bool btGenericMemoryPool::freeMemory(void * pointer)
|
||||
{
|
||||
unsigned char * pointer_pos = (unsigned char *)pointer;
|
||||
unsigned char * pool_pos = (unsigned char *)m_pool;
|
||||
@@ -228,14 +228,14 @@ void * btGenericPoolAllocator::allocate(size_t size_bytes)
|
||||
return failback_alloc(size_bytes);
|
||||
}
|
||||
|
||||
bool btGenericPoolAllocator::free(void * pointer)
|
||||
bool btGenericPoolAllocator::freeMemory(void * pointer)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
size_t i = 0;
|
||||
while(i<m_pool_count && result == false)
|
||||
{
|
||||
result = m_pools[i]->free(pointer);
|
||||
result = m_pools[i]->freeMemory(pointer);
|
||||
++i;
|
||||
}
|
||||
|
||||
@@ -279,5 +279,5 @@ void * btPoolRealloc(void *ptr, size_t oldsize, size_t newsize)
|
||||
|
||||
void btPoolFree(void *ptr)
|
||||
{
|
||||
g_main_allocator.free(ptr);
|
||||
g_main_allocator.freeMemory(ptr);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold)
|
||||
manifold->~btPersistentManifold();
|
||||
if (m_persistentManifoldPoolAllocator->validPtr(manifold))
|
||||
{
|
||||
m_persistentManifoldPoolAllocator->free(manifold);
|
||||
m_persistentManifoldPoolAllocator->freeMemory(manifold);
|
||||
} else
|
||||
{
|
||||
btAlignedFree(manifold);
|
||||
@@ -279,7 +279,7 @@ void btCollisionDispatcher::freeCollisionAlgorithm(void* ptr)
|
||||
{
|
||||
if (m_collisionAlgorithmPoolAllocator->validPtr(ptr))
|
||||
{
|
||||
m_collisionAlgorithmPoolAllocator->free(ptr);
|
||||
m_collisionAlgorithmPoolAllocator->freeMemory(ptr);
|
||||
} else
|
||||
{
|
||||
btAlignedFree(ptr);
|
||||
|
||||
@@ -32,7 +32,7 @@ void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
||||
gTotalBytesAlignedAllocs += size;
|
||||
gNumAlignedAllocs++;
|
||||
|
||||
printf("allocation#%d from %s,line %d, size %d\n",gNumAlignedAllocs,filename,line,size);
|
||||
|
||||
real = (char *)malloc(size + 2*sizeof(void *) + (alignment-1));
|
||||
if (real) {
|
||||
offset = (alignment - (unsigned long)(real + 2*sizeof(void *))) &
|
||||
@@ -44,6 +44,9 @@ void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
||||
} else {
|
||||
ret = (void *)(real);//??
|
||||
}
|
||||
|
||||
printf("allocation#%d at address %x, from %s,line %d, size %d\n",gNumAlignedAllocs,real, filename,line,size);
|
||||
|
||||
int* ptr = (int*)ret;
|
||||
*ptr = 12;
|
||||
return (ret);
|
||||
@@ -60,7 +63,7 @@ void btAlignedFreeInternal (void* ptr,int line,char* filename)
|
||||
int size = *((int*)(ptr)-2);
|
||||
gTotalBytesAlignedAllocs -= size;
|
||||
|
||||
printf("free #%d from %s,line %d, size %d\n",gNumAlignedFree,filename,line,size);
|
||||
printf("free #%d at address %x, from %s,line %d, size %d\n",gNumAlignedFree,real, filename,line,size);
|
||||
|
||||
free(real);
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user