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);
|
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);
|
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);
|
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 * pointer_pos = (unsigned char *)pointer;
|
||||||
unsigned char * pool_pos = (unsigned char *)m_pool;
|
unsigned char * pool_pos = (unsigned char *)m_pool;
|
||||||
@@ -228,14 +228,14 @@ void * btGenericPoolAllocator::allocate(size_t size_bytes)
|
|||||||
return failback_alloc(size_bytes);
|
return failback_alloc(size_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool btGenericPoolAllocator::free(void * pointer)
|
bool btGenericPoolAllocator::freeMemory(void * pointer)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while(i<m_pool_count && result == false)
|
while(i<m_pool_count && result == false)
|
||||||
{
|
{
|
||||||
result = m_pools[i]->free(pointer);
|
result = m_pools[i]->freeMemory(pointer);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,5 +279,5 @@ void * btPoolRealloc(void *ptr, size_t oldsize, size_t newsize)
|
|||||||
|
|
||||||
void btPoolFree(void *ptr)
|
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();
|
manifold->~btPersistentManifold();
|
||||||
if (m_persistentManifoldPoolAllocator->validPtr(manifold))
|
if (m_persistentManifoldPoolAllocator->validPtr(manifold))
|
||||||
{
|
{
|
||||||
m_persistentManifoldPoolAllocator->free(manifold);
|
m_persistentManifoldPoolAllocator->freeMemory(manifold);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
btAlignedFree(manifold);
|
btAlignedFree(manifold);
|
||||||
@@ -279,7 +279,7 @@ void btCollisionDispatcher::freeCollisionAlgorithm(void* ptr)
|
|||||||
{
|
{
|
||||||
if (m_collisionAlgorithmPoolAllocator->validPtr(ptr))
|
if (m_collisionAlgorithmPoolAllocator->validPtr(ptr))
|
||||||
{
|
{
|
||||||
m_collisionAlgorithmPoolAllocator->free(ptr);
|
m_collisionAlgorithmPoolAllocator->freeMemory(ptr);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
btAlignedFree(ptr);
|
btAlignedFree(ptr);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
|||||||
gTotalBytesAlignedAllocs += size;
|
gTotalBytesAlignedAllocs += size;
|
||||||
gNumAlignedAllocs++;
|
gNumAlignedAllocs++;
|
||||||
|
|
||||||
printf("allocation#%d from %s,line %d, size %d\n",gNumAlignedAllocs,filename,line,size);
|
|
||||||
real = (char *)malloc(size + 2*sizeof(void *) + (alignment-1));
|
real = (char *)malloc(size + 2*sizeof(void *) + (alignment-1));
|
||||||
if (real) {
|
if (real) {
|
||||||
offset = (alignment - (unsigned long)(real + 2*sizeof(void *))) &
|
offset = (alignment - (unsigned long)(real + 2*sizeof(void *))) &
|
||||||
@@ -44,6 +44,9 @@ void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filen
|
|||||||
} else {
|
} else {
|
||||||
ret = (void *)(real);//??
|
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;
|
int* ptr = (int*)ret;
|
||||||
*ptr = 12;
|
*ptr = 12;
|
||||||
return (ret);
|
return (ret);
|
||||||
@@ -60,7 +63,7 @@ void btAlignedFreeInternal (void* ptr,int line,char* filename)
|
|||||||
int size = *((int*)(ptr)-2);
|
int size = *((int*)(ptr)-2);
|
||||||
gTotalBytesAlignedAllocs -= size;
|
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);
|
free(real);
|
||||||
} else
|
} else
|
||||||
|
|||||||
Reference in New Issue
Block a user