Fix possible memory leaks
This commit is contained in:
parent
a14a92123c
commit
0b3abacb3c
|
@ -490,9 +490,7 @@ endif()
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Export GLFW library dependencies
|
# Export GLFW library dependencies
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
MESSAGE(BEFORE ${glfw_LIBRARIES})
|
|
||||||
set(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING "Dependencies of GLFW")
|
set(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING "Dependencies of GLFW")
|
||||||
MESSAGE(FINAL ${GLFW_LIBRARIES})
|
|
||||||
foreach(arg ${glfw_PKG_DEPS})
|
foreach(arg ${glfw_PKG_DEPS})
|
||||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
|
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
|
@ -107,7 +107,7 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mWorld.removeCollisionShape(proxyShape->mCollisionShape);
|
mWorld.removeCollisionShape(proxyShape->mCollisionShape);
|
||||||
current->ProxyShape::~ProxyShape();
|
current->~ProxyShape();
|
||||||
mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape));
|
mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape));
|
||||||
mNbCollisionShapes--;
|
mNbCollisionShapes--;
|
||||||
assert(mNbCollisionShapes >= 0);
|
assert(mNbCollisionShapes >= 0);
|
||||||
|
@ -129,7 +129,7 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mWorld.removeCollisionShape(proxyShape->mCollisionShape);
|
mWorld.removeCollisionShape(proxyShape->mCollisionShape);
|
||||||
elementToRemove->ProxyShape::~ProxyShape();
|
elementToRemove->~ProxyShape();
|
||||||
mWorld.mMemoryAllocator.release(elementToRemove, sizeof(ProxyShape));
|
mWorld.mMemoryAllocator.release(elementToRemove, sizeof(ProxyShape));
|
||||||
mNbCollisionShapes--;
|
mNbCollisionShapes--;
|
||||||
return;
|
return;
|
||||||
|
@ -160,7 +160,7 @@ void CollisionBody::removeAllCollisionShapes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
mWorld.removeCollisionShape(current->mCollisionShape);
|
mWorld.removeCollisionShape(current->mCollisionShape);
|
||||||
current->ProxyShape::~ProxyShape();
|
current->~ProxyShape();
|
||||||
mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape));
|
mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape));
|
||||||
|
|
||||||
// Get the next element in the list
|
// Get the next element in the list
|
||||||
|
@ -179,7 +179,7 @@ void CollisionBody::resetContactManifoldsList() {
|
||||||
ContactManifoldListElement* nextElement = currentElement->next;
|
ContactManifoldListElement* nextElement = currentElement->next;
|
||||||
|
|
||||||
// Delete the current element
|
// Delete the current element
|
||||||
currentElement->ContactManifoldListElement::~ContactManifoldListElement();
|
currentElement->~ContactManifoldListElement();
|
||||||
mWorld.mMemoryAllocator.release(currentElement, sizeof(ContactManifoldListElement));
|
mWorld.mMemoryAllocator.release(currentElement, sizeof(ContactManifoldListElement));
|
||||||
|
|
||||||
currentElement = nextElement;
|
currentElement = nextElement;
|
||||||
|
|
|
@ -147,7 +147,7 @@ void RigidBody::removeJointFromJointsList(MemoryAllocator& memoryAllocator, cons
|
||||||
if (mJointsList->joint == joint) { // If the first element is the one to remove
|
if (mJointsList->joint == joint) { // If the first element is the one to remove
|
||||||
JointListElement* elementToRemove = mJointsList;
|
JointListElement* elementToRemove = mJointsList;
|
||||||
mJointsList = elementToRemove->next;
|
mJointsList = elementToRemove->next;
|
||||||
elementToRemove->JointListElement::~JointListElement();
|
elementToRemove->~JointListElement();
|
||||||
memoryAllocator.release(elementToRemove, sizeof(JointListElement));
|
memoryAllocator.release(elementToRemove, sizeof(JointListElement));
|
||||||
}
|
}
|
||||||
else { // If the element to remove is not the first one in the list
|
else { // If the element to remove is not the first one in the list
|
||||||
|
@ -156,7 +156,7 @@ void RigidBody::removeJointFromJointsList(MemoryAllocator& memoryAllocator, cons
|
||||||
if (currentElement->next->joint == joint) {
|
if (currentElement->next->joint == joint) {
|
||||||
JointListElement* elementToRemove = currentElement->next;
|
JointListElement* elementToRemove = currentElement->next;
|
||||||
currentElement->next = elementToRemove->next;
|
currentElement->next = elementToRemove->next;
|
||||||
elementToRemove->JointListElement::~JointListElement();
|
elementToRemove->~JointListElement();
|
||||||
memoryAllocator.release(elementToRemove, sizeof(JointListElement));
|
memoryAllocator.release(elementToRemove, sizeof(JointListElement));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ void CollisionDetection::reportCollisionBetweenShapes(CollisionCallback* callbac
|
||||||
if (callback != NULL) callback->notifyContact(*contactInfo);
|
if (callback != NULL) callback->notifyContact(*contactInfo);
|
||||||
|
|
||||||
// Delete and remove the contact info from the memory allocator
|
// Delete and remove the contact info from the memory allocator
|
||||||
contactInfo->ContactPointInfo::~ContactPointInfo();
|
contactInfo->~ContactPointInfo();
|
||||||
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
|
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ void CollisionDetection::computeNarrowPhase() {
|
||||||
++it;
|
++it;
|
||||||
|
|
||||||
// Destroy the overlapping pair
|
// Destroy the overlapping pair
|
||||||
itToRemove->second->OverlappingPair::~OverlappingPair();
|
itToRemove->second->~OverlappingPair();
|
||||||
mWorld->mMemoryAllocator.release(itToRemove->second, sizeof(OverlappingPair));
|
mWorld->mMemoryAllocator.release(itToRemove->second, sizeof(OverlappingPair));
|
||||||
mOverlappingPairs.erase(itToRemove);
|
mOverlappingPairs.erase(itToRemove);
|
||||||
continue;
|
continue;
|
||||||
|
@ -233,7 +233,7 @@ void CollisionDetection::computeNarrowPhase() {
|
||||||
if (mWorld->mEventListener != NULL) mWorld->mEventListener->newContact(*contactInfo);
|
if (mWorld->mEventListener != NULL) mWorld->mEventListener->newContact(*contactInfo);
|
||||||
|
|
||||||
// Delete and remove the contact info from the memory allocator
|
// Delete and remove the contact info from the memory allocator
|
||||||
contactInfo->ContactPointInfo::~ContactPointInfo();
|
contactInfo->~ContactPointInfo();
|
||||||
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
|
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* call
|
||||||
++it;
|
++it;
|
||||||
|
|
||||||
// Destroy the overlapping pair
|
// Destroy the overlapping pair
|
||||||
itToRemove->second->OverlappingPair::~OverlappingPair();
|
itToRemove->second->~OverlappingPair();
|
||||||
mWorld->mMemoryAllocator.release(itToRemove->second, sizeof(OverlappingPair));
|
mWorld->mMemoryAllocator.release(itToRemove->second, sizeof(OverlappingPair));
|
||||||
mOverlappingPairs.erase(itToRemove);
|
mOverlappingPairs.erase(itToRemove);
|
||||||
continue;
|
continue;
|
||||||
|
@ -331,7 +331,7 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* call
|
||||||
if (callback != NULL) callback->notifyContact(*contactInfo);
|
if (callback != NULL) callback->notifyContact(*contactInfo);
|
||||||
|
|
||||||
// Delete and remove the contact info from the memory allocator
|
// Delete and remove the contact info from the memory allocator
|
||||||
contactInfo->ContactPointInfo::~ContactPointInfo();
|
contactInfo->~ContactPointInfo();
|
||||||
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
|
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ void CollisionDetection::removeProxyCollisionShape(ProxyShape* proxyShape) {
|
||||||
++it;
|
++it;
|
||||||
|
|
||||||
// Destroy the overlapping pair
|
// Destroy the overlapping pair
|
||||||
itToRemove->second->OverlappingPair::~OverlappingPair();
|
itToRemove->second->~OverlappingPair();
|
||||||
mWorld->mMemoryAllocator.release(itToRemove->second, sizeof(OverlappingPair));
|
mWorld->mMemoryAllocator.release(itToRemove->second, sizeof(OverlappingPair));
|
||||||
mOverlappingPairs.erase(itToRemove);
|
mOverlappingPairs.erase(itToRemove);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ void CollisionWorld::destroyCollisionBody(CollisionBody* collisionBody) {
|
||||||
mFreeBodiesIDs.push_back(collisionBody->getID());
|
mFreeBodiesIDs.push_back(collisionBody->getID());
|
||||||
|
|
||||||
// Call the destructor of the collision body
|
// Call the destructor of the collision body
|
||||||
collisionBody->CollisionBody::~CollisionBody();
|
collisionBody->~CollisionBody();
|
||||||
|
|
||||||
// Remove the collision body from the list of bodies
|
// Remove the collision body from the list of bodies
|
||||||
mBodies.erase(collisionBody);
|
mBodies.erase(collisionBody);
|
||||||
|
@ -159,7 +159,7 @@ void CollisionWorld::removeCollisionShape(CollisionShape* collisionShape) {
|
||||||
size_t nbBytesShape = collisionShape->getSizeInBytes();
|
size_t nbBytesShape = collisionShape->getSizeInBytes();
|
||||||
|
|
||||||
// Call the destructor of the collision shape
|
// Call the destructor of the collision shape
|
||||||
collisionShape->CollisionShape::~CollisionShape();
|
collisionShape->~CollisionShape();
|
||||||
|
|
||||||
// Deallocate the memory used by the collision shape
|
// Deallocate the memory used by the collision shape
|
||||||
mMemoryAllocator.release(collisionShape, nbBytesShape);
|
mMemoryAllocator.release(collisionShape, nbBytesShape);
|
||||||
|
|
|
@ -56,7 +56,7 @@ void ContactManifold::addContactPoint(ContactPoint* contact) {
|
||||||
if (distance <= PERSISTENT_CONTACT_DIST_THRESHOLD*PERSISTENT_CONTACT_DIST_THRESHOLD) {
|
if (distance <= PERSISTENT_CONTACT_DIST_THRESHOLD*PERSISTENT_CONTACT_DIST_THRESHOLD) {
|
||||||
|
|
||||||
// Delete the new contact
|
// Delete the new contact
|
||||||
contact->ContactPoint::~ContactPoint();
|
contact->~ContactPoint();
|
||||||
mMemoryAllocator.release(contact, sizeof(ContactPoint));
|
mMemoryAllocator.release(contact, sizeof(ContactPoint));
|
||||||
//removeContact(i);
|
//removeContact(i);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void ContactManifold::removeContactPoint(uint index) {
|
||||||
|
|
||||||
// Call the destructor explicitly and tell the memory allocator that
|
// Call the destructor explicitly and tell the memory allocator that
|
||||||
// the corresponding memory block is now free
|
// the corresponding memory block is now free
|
||||||
mContactPoints[index]->ContactPoint::~ContactPoint();
|
mContactPoints[index]->~ContactPoint();
|
||||||
mMemoryAllocator.release(mContactPoints[index], sizeof(ContactPoint));
|
mMemoryAllocator.release(mContactPoints[index], sizeof(ContactPoint));
|
||||||
|
|
||||||
// If we don't remove the last index
|
// If we don't remove the last index
|
||||||
|
@ -253,7 +253,7 @@ void ContactManifold::clear() {
|
||||||
|
|
||||||
// Call the destructor explicitly and tell the memory allocator that
|
// Call the destructor explicitly and tell the memory allocator that
|
||||||
// the corresponding memory block is now free
|
// the corresponding memory block is now free
|
||||||
mContactPoints[i]->ContactPoint::~ContactPoint();
|
mContactPoints[i]->~ContactPoint();
|
||||||
mMemoryAllocator.release(mContactPoints[i], sizeof(ContactPoint));
|
mMemoryAllocator.release(mContactPoints[i], sizeof(ContactPoint));
|
||||||
}
|
}
|
||||||
mNbContactPoints = 0;
|
mNbContactPoints = 0;
|
||||||
|
|
|
@ -60,7 +60,7 @@ DynamicsWorld::~DynamicsWorld() {
|
||||||
for (uint i=0; i<mNbIslands; i++) {
|
for (uint i=0; i<mNbIslands; i++) {
|
||||||
|
|
||||||
// Call the island destructor
|
// Call the island destructor
|
||||||
mIslands[i]->Island::~Island();
|
mIslands[i]->~Island();
|
||||||
|
|
||||||
// Release the allocated memory for the island
|
// Release the allocated memory for the island
|
||||||
mMemoryAllocator.release(mIslands[i], sizeof(Island));
|
mMemoryAllocator.release(mIslands[i], sizeof(Island));
|
||||||
|
@ -497,7 +497,7 @@ void DynamicsWorld::destroyRigidBody(RigidBody* rigidBody) {
|
||||||
rigidBody->resetContactManifoldsList();
|
rigidBody->resetContactManifoldsList();
|
||||||
|
|
||||||
// Call the destructor of the rigid body
|
// Call the destructor of the rigid body
|
||||||
rigidBody->RigidBody::~RigidBody();
|
rigidBody->~RigidBody();
|
||||||
|
|
||||||
// Remove the rigid body from the list of rigid bodies
|
// Remove the rigid body from the list of rigid bodies
|
||||||
mBodies.erase(rigidBody);
|
mBodies.erase(rigidBody);
|
||||||
|
@ -602,7 +602,7 @@ void DynamicsWorld::destroyJoint(Joint* joint) {
|
||||||
size_t nbBytes = joint->getSizeInBytes();
|
size_t nbBytes = joint->getSizeInBytes();
|
||||||
|
|
||||||
// Call the destructor of the joint
|
// Call the destructor of the joint
|
||||||
joint->Joint::~Joint();
|
joint->~Joint();
|
||||||
|
|
||||||
// Release the allocated memory
|
// Release the allocated memory
|
||||||
mMemoryAllocator.release(joint, nbBytes);
|
mMemoryAllocator.release(joint, nbBytes);
|
||||||
|
@ -643,7 +643,7 @@ void DynamicsWorld::computeIslands() {
|
||||||
for (uint i=0; i<mNbIslands; i++) {
|
for (uint i=0; i<mNbIslands; i++) {
|
||||||
|
|
||||||
// Call the island destructor
|
// Call the island destructor
|
||||||
mIslands[i]->Island::~Island();
|
mIslands[i]->~Island();
|
||||||
|
|
||||||
// Release the allocated memory for the island
|
// Release the allocated memory for the island
|
||||||
mMemoryAllocator.release(mIslands[i], sizeof(Island));
|
mMemoryAllocator.release(mIslands[i], sizeof(Island));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user