From d6446e9b14951fb49764a6fed7d31cb1213f74df Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 11 Nov 2013 16:07:46 -0800 Subject: [PATCH] calls `delete[]` instead of `delete` calls `delete[]` instead of `delete` --- cocos/2d/platform/ios/CCDevice.mm | 6 ++++-- cocos/physics/CCPhysicsShape.cpp | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cocos/2d/platform/ios/CCDevice.mm b/cocos/2d/platform/ios/CCDevice.mm index 4555b14df2..e8610db653 100644 --- a/cocos/2d/platform/ios/CCDevice.mm +++ b/cocos/2d/platform/ios/CCDevice.mm @@ -37,8 +37,10 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher; - (id) init { - _acceleration = new cocos2d::Acceleration(); - _motionManager = [[CMMotionManager alloc] init]; + if( (self = [super init]) ) { + _acceleration = new cocos2d::Acceleration(); + _motionManager = [[CMMotionManager alloc] init]; + } return self; } diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index bb043b027a..91df06d1ea 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -539,7 +539,7 @@ bool PhysicsShapePolygon::init(const Point* points, int count, const PhysicsMate cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), count, vecs, PhysicsHelper::point2cpv(offset)); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); CC_BREAK_IF(shape == nullptr); @@ -563,7 +563,7 @@ float PhysicsShapePolygon::calculateArea(const Point* points, int count) cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs)); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); return area; } @@ -574,7 +574,7 @@ float PhysicsShapePolygon::calculateMoment(float mass, const Point* points, int PhysicsHelper::points2cpvs(points, vecs, count); float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset))); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); return moment; }