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