diff --git a/cocos2dx/CCConfiguration.cpp b/cocos2dx/CCConfiguration.cpp index 22a1a01434..af59977c4d 100644 --- a/cocos2dx/CCConfiguration.cpp +++ b/cocos2dx/CCConfiguration.cpp @@ -36,6 +36,14 @@ static CCConfiguration g_SharedConfiguration; static char *g_pGlExtensions; CCConfiguration::CCConfiguration(void) +: m_bSupportsBGRA8888(false) +, m_bSupportsDiscardFramebuffer(false) +, m_bSupportsNPOT(false) +, m_bSupportsPVRTC(false) +, m_nMaxModelviewStackDepth(0) +, m_nMaxSamplesAllowed(0) +, m_nMaxTextureSize(0) +, m_uOSVersion(0) { } diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index b33ad60b06..8d7772a771 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -128,6 +128,14 @@ void CCTimer::update(ccTime dt) static CCScheduler *pSharedScheduler; CCScheduler::CCScheduler(void) +: m_bCurrentTargetSalvaged(false) +, m_fTimeScale(0.0) +, m_pCurrentTarget(NULL) +, m_pHashForSelectors(NULL) +, m_pHashForUpdates(NULL) +, m_pUpdates0List(NULL) +, m_pUpdatesNegList(NULL) +, m_pUpdatesPosList(NULL) { assert(pSharedScheduler == NULL); } diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index e9a5c744e0..711cc985ef 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -194,7 +194,7 @@ CCActionInterval *CCSpeed::reverse() // CCFollow::~CCFollow() { - m_pobFollowedNode->release(); + CC_SAFE_RELEASE(m_pobFollowedNode); } CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode) diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index baa7823a63..994dde7db1 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -32,9 +32,7 @@ namespace cocos2d { // InstantAction // CCActionInstant::CCActionInstant() - { - m_fDuration = 0; - } + {} CCObject * CCActionInstant::copyWithZone(cocos2d::CCZone *pZone) { @@ -412,13 +410,13 @@ namespace cocos2d { // CCCallFuncO // CCCallFuncO::CCCallFuncO() + : m_pObject(NULL) { - m_pTarget = NULL; } CCCallFuncO::~CCCallFuncO() { - m_pTarget->release(); + CC_SAFE_RELEASE(m_pObject); } void CCCallFuncO::execute() diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index cba8796e4e..bf177ef4d9 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -225,8 +225,8 @@ CCObject* CCSequence::copyWithZone(CCZone *pZone) CCSequence::~CCSequence(void) { - m_pActions[0]->release(); - m_pActions[1]->release(); + CC_SAFE_RELEASE(m_pActions[0]); + CC_SAFE_RELEASE(m_pActions[1]); } void CCSequence::startWithTarget(CCNode *pTarget) @@ -356,7 +356,7 @@ CCObject* CCRepeat::copyWithZone(cocos2d::CCZone *pZone) CCRepeat::~CCRepeat(void) { - m_pOther->release(); + CC_SAFE_RELEASE(m_pOther); } void CCRepeat::startWithTarget(CCNode *pTarget) @@ -429,7 +429,7 @@ CCActionInterval* CCRepeat::reverse(void) // CCRepeatForever::~CCRepeatForever() { - m_pOther->release(); + CC_SAFE_RELEASE(m_pOther); } CCRepeatForever *CCRepeatForever::actionWithAction(CCActionInterval *pAction) { @@ -591,8 +591,8 @@ CCObject* CCSpawn::copyWithZone(cocos2d::CCZone *pZone) CCSpawn::~CCSpawn(void) { - m_pOne->release(); - m_pTwo->release(); + CC_SAFE_RELEASE(m_pOne); + CC_SAFE_RELEASE(m_pTwo); } void CCSpawn::startWithTarget(CCNode *pTarget) @@ -1769,7 +1769,7 @@ CCObject* CCReverseTime::copyWithZone(cocos2d::CCZone *pZone) CCReverseTime::~CCReverseTime(void) { - m_pOther->release(); + CC_SAFE_RELEASE(m_pOther); } void CCReverseTime::startWithTarget(CCNode *pTarget) diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index 5f8d44a014..adc4f88d4e 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -84,6 +84,9 @@ void CCActionManager::selectorProtocolRelease() } CCActionManager::CCActionManager(void) +: m_pCurrentTarget(NULL), + m_pTargets(NULL), + m_bCurrentTargetSalvaged(false) { assert(gSharedManager == NULL); } diff --git a/cocos2dx/actions/CCActionTiledGrid.cpp b/cocos2dx/actions/CCActionTiledGrid.cpp index 35badedbda..dbd582d698 100644 --- a/cocos2dx/actions/CCActionTiledGrid.cpp +++ b/cocos2dx/actions/CCActionTiledGrid.cpp @@ -288,15 +288,8 @@ namespace cocos2d CCShuffleTiles::~CCShuffleTiles(void) { - if (m_pTilesOrder) - { - delete[] m_pTilesOrder; - } - - if (m_pTiles) - { - delete[] m_pTiles; - } + CC_SAFE_DELETE_ARRAY(m_pTilesOrder); + CC_SAFE_DELETE_ARRAY(m_pTiles); } void CCShuffleTiles::shuffle(int *pArray, int nLen) @@ -662,10 +655,7 @@ namespace cocos2d CCTurnOffTiles::~CCTurnOffTiles(void) { - if (m_pTilesOrder) - { - delete[] m_pTilesOrder; - } + CC_SAFE_DELETE_ARRAY(m_pTilesOrder); } void CCTurnOffTiles::shuffle(int *pArray, int nLen) diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index c209399e74..27adc86ab0 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -33,12 +33,19 @@ namespace cocos2d { // CCAtlasNode - Creation & Init CCAtlasNode::CCAtlasNode() +: m_pTextureAtlas(NULL) +, m_bIsOpacityModifyRGB(false) +, m_nItemWidth(0) +, m_nItemHeight(0) +, m_cOpacity(0) +, m_nItemsPerRow(0) +, m_nItemsPerColumn(0) { } CCAtlasNode::~CCAtlasNode() { - m_pTextureAtlas->release(); + CC_SAFE_RELEASE(m_pTextureAtlas); } CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, int tileWidth, int tileHeight, int itemsToRender) diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index a488b669e6..039a28a9bc 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -35,7 +35,7 @@ CCAutoreleasePool::CCAutoreleasePool(void) CCAutoreleasePool::~CCAutoreleasePool(void) { - delete m_pManagedObjectArray; + CC_SAFE_DELETE(m_pManagedObjectArray); } void CCAutoreleasePool::addObject(CCObject* pObject) @@ -105,7 +105,7 @@ CCPoolManager::~CCPoolManager() m_pCurReleasePool = NULL; m_pReleasePoolStack->removeObjectAtIndex(0); - delete m_pReleasePoolStack; + CC_SAFE_DELETE(m_pReleasePoolStack); } void CCPoolManager::finalize() diff --git a/cocos2dx/cocoa/CCData.cpp b/cocos2dx/cocoa/CCData.cpp index 4d258e8ed0..01539c3fa9 100644 --- a/cocos2dx/cocoa/CCData.cpp +++ b/cocos2dx/cocoa/CCData.cpp @@ -32,16 +32,13 @@ using namespace std; namespace cocos2d { CCData::CCData(void) +: m_pData(NULL) { - m_pData = NULL; } CCData::~CCData(void) { - if (m_pData) - { - delete[] m_pData; - } + CC_SAFE_DELETE_ARRAY(m_pData); } CCData* CCData::dataWithContentsOfFile(const string &strPath) diff --git a/cocos2dx/cocoa/CCSet.cpp b/cocos2dx/cocoa/CCSet.cpp index 426b5b0101..557835fae6 100644 --- a/cocos2dx/cocoa/CCSet.cpp +++ b/cocos2dx/cocoa/CCSet.cpp @@ -40,11 +40,7 @@ CCSet::CCSet(const CCSet &rSetObject) CCSet::~CCSet(void) { - if (m_pSet) - { - delete m_pSet; - m_pSet = NULL; - } + CC_SAFE_DELETE(m_pSet); } CCSet* CCSet::copy(void) diff --git a/cocos2dx/effects/CCGrabber.cpp b/cocos2dx/effects/CCGrabber.cpp index 7be470e136..e511f19491 100644 --- a/cocos2dx/effects/CCGrabber.cpp +++ b/cocos2dx/effects/CCGrabber.cpp @@ -30,10 +30,9 @@ THE SOFTWARE. namespace cocos2d { CCGrabber::CCGrabber(void) + : m_fbo(0) + , m_oldFBO(0) { - m_fbo = 0; - m_oldFBO = 0; - // generate FBO ccglGenFramebuffers(1, &m_fbo); } diff --git a/cocos2dx/event_dispatcher/CCKeyboardEventDelegate.cpp b/cocos2dx/event_dispatcher/CCKeyboardEventDelegate.cpp index b73a68041f..0040e8fd51 100644 --- a/cocos2dx/event_dispatcher/CCKeyboardEventDelegate.cpp +++ b/cocos2dx/event_dispatcher/CCKeyboardEventDelegate.cpp @@ -39,7 +39,10 @@ namespace cocos2d { CCKeyboardEventHandle::~CCKeyboardEventHandle() { - m_pDelegate->KeyboardDestroy(); + if (m_pDelegate) + { + m_pDelegate->KeyboardDestroy(); + } } void CCKeyboardEventHandle::setDelegate(CCKeyboardEventDelegate *pDelegate) diff --git a/cocos2dx/event_dispatcher/CCMouseEventDelegate.cpp b/cocos2dx/event_dispatcher/CCMouseEventDelegate.cpp index 289c539471..bb1b9f7d8b 100644 --- a/cocos2dx/event_dispatcher/CCMouseEventDelegate.cpp +++ b/cocos2dx/event_dispatcher/CCMouseEventDelegate.cpp @@ -39,7 +39,10 @@ namespace cocos2d { CCMouseEventHandle::~CCMouseEventHandle() { - m_pDelegate->MouseDestroy(); + if (m_pDelegate) + { + m_pDelegate->MouseDestroy(); + } } void CCMouseEventHandle::setDelegate(CCMouseEventDelegate *pDelegate) diff --git a/cocos2dx/include/CCAction.h b/cocos2dx/include/CCAction.h index 79874ae389..16fc2d6ed8 100644 --- a/cocos2dx/include/CCAction.h +++ b/cocos2dx/include/CCAction.h @@ -119,7 +119,9 @@ protected: class CC_DLL CCFiniteTimeAction : public CCAction { public: - CCFiniteTimeAction(){} + CCFiniteTimeAction() + : m_fDuration(0) + {} virtual ~CCFiniteTimeAction(){} //! get duration in seconds of the action inline ccTime getDuration(void) { return m_fDuration; } @@ -145,7 +147,10 @@ class CCRepeatForever; class CC_DLL CCSpeed : public CCAction { public: - CCSpeed(){} + CCSpeed() + : m_fSpeed(0.0) + , m_pOther(NULL) + {} virtual ~CCSpeed(void); inline float getSpeed(void) { return m_fSpeed; } @@ -187,7 +192,15 @@ Instead of using CCCamera as a "follower", use this action instead. class CC_DLL CCFollow : public CCAction { public: - CCFollow(){} + CCFollow() + : m_pobFollowedNode(NULL) + , m_bBoundaryFullyCovered(false) + , m_bBoundarySet(false) + , m_fBottomBoundary(0.0) + , m_fLeftBoundary(0.0) + , m_fRightBoundary(0.0) + , m_fTopBoundary(0.0) + {} virtual ~CCFollow(void); inline bool isBoundarySet(void) { return m_bBoundarySet; } diff --git a/cocos2dx/include/CCActionCamera.h b/cocos2dx/include/CCActionCamera.h index e1b4980a67..92d8c8d9f0 100644 --- a/cocos2dx/include/CCActionCamera.h +++ b/cocos2dx/include/CCActionCamera.h @@ -72,7 +72,18 @@ namespace cocos2d { class CC_DLL CCOrbitCamera : public CCActionCamera // { public: - CCOrbitCamera(){} + CCOrbitCamera() + : m_fAngleX(0.0) + , m_fAngleZ(0.0) + , m_fDeltaAngleX(0.0) + , m_fDeltaAngleZ(0.0) + , m_fDeltaRadius(0.0) + , m_fRadDeltaX(0.0) + , m_fRadDeltaZ(0.0) + , m_fRadius(0.0) + , m_fRadX(0.0) + , m_fRadZ(0.0) + {} ~CCOrbitCamera(){} /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ static CCOrbitCamera * actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); diff --git a/cocos2dx/include/CCActionInstant.h b/cocos2dx/include/CCActionInstant.h index 8976c876b2..b87d70144d 100644 --- a/cocos2dx/include/CCActionInstant.h +++ b/cocos2dx/include/CCActionInstant.h @@ -104,7 +104,9 @@ namespace cocos2d { class CC_DLL CCFlipX : public CCActionInstant { public: - CCFlipX(){} + CCFlipX() + :m_bFlipX(false) + {} virtual ~CCFlipX(){} /** create the action */ @@ -127,7 +129,9 @@ namespace cocos2d { class CC_DLL CCFlipY : public CCActionInstant { public: - CCFlipY(){} + CCFlipY() + :m_bFlipY(false) + {} virtual ~CCFlipY(){} /** create the action */ @@ -167,9 +171,9 @@ namespace cocos2d { { public: CCCallFunc() + : m_pCallFunc(NULL) + , m_pSelectorTarget(NULL) { - m_pCallFunc = NULL; - m_pSelectorTarget = NULL; } virtual ~CCCallFunc() { diff --git a/cocos2dx/include/CCActionInterval.h b/cocos2dx/include/CCActionInterval.h index 386d48af63..e38e84f272 100644 --- a/cocos2dx/include/CCActionInterval.h +++ b/cocos2dx/include/CCActionInterval.h @@ -146,7 +146,9 @@ To repeat the an action for a limited number of times use the Repeat action. class CC_DLL CCRepeatForever : public CCActionInterval { public: - CCRepeatForever(){} + CCRepeatForever() + : m_pOther(NULL) + {} virtual ~CCRepeatForever(); /** initializes the action */ diff --git a/cocos2dx/include/CCDirector.h b/cocos2dx/include/CCDirector.h index fad50a044c..50c349ffde 100644 --- a/cocos2dx/include/CCDirector.h +++ b/cocos2dx/include/CCDirector.h @@ -578,7 +578,9 @@ protected: class CCDisplayLinkDirector : public CCDirector { public: - CCDisplayLinkDirector(void) {} + CCDisplayLinkDirector(void) + : m_bInvalid(false) + {} virtual void mainLoop(void); virtual void setAnimationInterval(double dValue); diff --git a/cocos2dx/include/CCLabelBMFont.h b/cocos2dx/include/CCLabelBMFont.h index 83ccbf04cf..9b621bb584 100644 --- a/cocos2dx/include/CCLabelBMFont.h +++ b/cocos2dx/include/CCLabelBMFont.h @@ -85,7 +85,8 @@ namespace cocos2d{ struct _KerningHashElement *m_pKerningDictionary; public: CCBMFontConfiguration() - :m_pKerningDictionary(NULL) + : m_pKerningDictionary(NULL) + , m_uCommonHeight(0) {} virtual ~CCBMFontConfiguration(); char * description(); @@ -147,7 +148,10 @@ namespace cocos2d{ CCBMFontConfiguration *m_pConfiguration; public: CCLabelBMFont() - :m_pConfiguration(NULL) + : m_pConfiguration(NULL) + , m_bIsOpacityModifyRGB(false) + , m_cOpacity(0) + , m_sString("") {} virtual ~CCLabelBMFont(); /** Purges the cached data. diff --git a/cocos2dx/include/CCMenu.h b/cocos2dx/include/CCMenu.h index 70ddc473ac..1c63cde01c 100644 --- a/cocos2dx/include/CCMenu.h +++ b/cocos2dx/include/CCMenu.h @@ -50,7 +50,10 @@ namespace cocos2d{ class CC_DLL CCMenu : public CCLayer, public CCRGBAProtocol { public: - CCMenu(){} + CCMenu() + : m_cOpacity(0) + , m_pSelectedItem(NULL) + {} virtual ~CCMenu(){} /** creates a CCMenu with it's items */ static CCMenu* menuWithItems(CCMenuItem* item, ...); diff --git a/cocos2dx/include/CCMenuItem.h b/cocos2dx/include/CCMenuItem.h index a4a79e9ee2..be4a9c8f24 100644 --- a/cocos2dx/include/CCMenuItem.h +++ b/cocos2dx/include/CCMenuItem.h @@ -51,7 +51,10 @@ namespace cocos2d{ CC_PROPERTY(bool, m_bIsEnabled, IsEnabled); public: CCMenuItem() - :m_pListener(NULL) + : m_pListener(NULL) + , m_bIsEnabled(false) + , m_bIsSelected(false) + , m_pfnSelector(NULL) {} virtual ~CCMenuItem(){} /** Creates a CCMenuItem with a target/selector */ @@ -86,7 +89,8 @@ namespace cocos2d{ CC_PROPERTY(CCNode*, m_pLabel, Label); public: CCMenuItemLabel() - :m_pLabel(NULL) + : m_pLabel(NULL) + , m_fOriginalScale(0.0) {} virtual ~CCMenuItemLabel(); /** creates a CCMenuItemLabel with a Label, target and selector */ @@ -247,7 +251,11 @@ namespace cocos2d{ */ CC_PROPERTY(CCMutableArray*, m_pSubItems, SubItems); public: - CCMenuItemToggle(){} + CCMenuItemToggle() + : m_cOpacity(0) + , m_pSubItems(NULL) + , m_uSelectedIndex(0) + {} virtual ~CCMenuItemToggle(); /** creates a menu item from a list of items with a target/selector */ static CCMenuItemToggle* itemWithTarget(SelectorProtocol* target, SEL_MenuHandler selector, CCMenuItem* item, ...); diff --git a/cocos2dx/include/CCMotionStreak.h b/cocos2dx/include/CCMotionStreak.h index 1fca02d344..b9d91a0272 100644 --- a/cocos2dx/include/CCMotionStreak.h +++ b/cocos2dx/include/CCMotionStreak.h @@ -56,7 +56,12 @@ class CC_DLL CCMotionStreak : public CCNode, public CCTextureProtocol CC_PROPERTY(CCTexture2D*, m_pTexture, Texture) CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc) public: - CCMotionStreak(){} + CCMotionStreak() + : m_fSegThreshold(0.0) + , m_fWidth(0.0) + , m_pRibbon(NULL) + , m_pTexture(NULL) + {} virtual ~CCMotionStreak(){} /** creates the a MotionStreak. The image will be loaded using the TextureMgr. */ static CCMotionStreak * streakWithFade(float fade, float seg, const char *imagePath, float width, float length, ccColor4B color); diff --git a/cocos2dx/include/CCRibbon.h b/cocos2dx/include/CCRibbon.h index c23c5b78a4..0fef2fa4ff 100644 --- a/cocos2dx/include/CCRibbon.h +++ b/cocos2dx/include/CCRibbon.h @@ -106,7 +106,11 @@ public: unsigned int m_uEnd; unsigned int m_uBegin; public: - CCRibbonSegment(){} + CCRibbonSegment() + : m_bFinished(false) + , m_uBegin(0) + , m_uEnd(0) + {} virtual ~CCRibbonSegment(); char * description(); bool init(); diff --git a/cocos2dx/include/CCSpriteFrameCache.h b/cocos2dx/include/CCSpriteFrameCache.h index 19f832f898..68945d92d7 100644 --- a/cocos2dx/include/CCSpriteFrameCache.h +++ b/cocos2dx/include/CCSpriteFrameCache.h @@ -131,7 +131,7 @@ public: static void purgeSharedSpriteFrameCache(void); private: - CCSpriteFrameCache(void) {} + CCSpriteFrameCache(void) : m_pSpriteFrames(NULL), m_pSpriteFramesAliases(NULL){} const char * valueForKey(const char *key, CCDictionary *dict); protected: diff --git a/cocos2dx/include/CCTouchDispatcher.h b/cocos2dx/include/CCTouchDispatcher.h index 6d9c08178e..2ff252375a 100644 --- a/cocos2dx/include/CCTouchDispatcher.h +++ b/cocos2dx/include/CCTouchDispatcher.h @@ -95,7 +95,12 @@ class CC_DLL CCTouchDispatcher : public CCObject, public EGLTouchDelegate public: ~CCTouchDispatcher(); bool init(void); - CCTouchDispatcher() {} + CCTouchDispatcher() + : m_pHandlersToAdd(NULL) + , m_pHandlersToRemove(NULL) + , m_pStandardHandlers(NULL) + , m_pTargetedHandlers(NULL) + {} public: /** Whether or not the events are going to be dispatched. Default: true */ diff --git a/cocos2dx/keypad_dispatcher/CCKeypadDelegate.cpp b/cocos2dx/keypad_dispatcher/CCKeypadDelegate.cpp index b439177c93..4880df8627 100644 --- a/cocos2dx/keypad_dispatcher/CCKeypadDelegate.cpp +++ b/cocos2dx/keypad_dispatcher/CCKeypadDelegate.cpp @@ -39,7 +39,10 @@ CCKeypadDelegate* CCKeypadHandler::getDelegate() CCKeypadHandler::~CCKeypadHandler() { - m_pDelegate->KeypadDestroy(); + if (m_pDelegate) + { + m_pDelegate->KeypadDestroy(); + } } void CCKeypadHandler::setDelegate(CCKeypadDelegate *pDelegate) diff --git a/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp b/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp index b418415607..b938262230 100644 --- a/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp +++ b/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp @@ -46,9 +46,16 @@ CCKeypadDispatcher::CCKeypadDispatcher() CCKeypadDispatcher::~CCKeypadDispatcher() { - m_pDelegates->release(); - ccCArrayFree(m_pHandlersToAdd); - ccCArrayFree(m_pHandlersToRemove); + CC_SAFE_RELEASE(m_pDelegates); + if (m_pHandlersToAdd) + { + ccCArrayFree(m_pHandlersToAdd); + } + + if (m_pHandlersToRemove) + { + ccCArrayFree(m_pHandlersToRemove); + } } CCKeypadDispatcher* CCKeypadDispatcher::sharedDispatcher() diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index f2f900b7fa..7932cd4774 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -412,7 +412,7 @@ namespace cocos2d{ CCLabelBMFont::~CCLabelBMFont() { m_sString.clear(); - m_pConfiguration->release(); + CC_SAFE_RELEASE(m_pConfiguration); } // BitmapFontAtlas - Atlas generation diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 83fecc18b1..ca25edf7b1 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -31,23 +31,15 @@ namespace cocos2d{ CCLabelTTF::CCLabelTTF() : m_pFontName(NULL) , m_pString(NULL) + , m_fFontSize(0.0) + , m_eAlignment(CCTextAlignmentCenter) { } CCLabelTTF::~CCLabelTTF() { - if (m_pFontName) - { - delete m_pFontName; - m_pFontName = NULL; - } - - if (m_pString) - { - delete m_pString; - m_pString = NULL; - } - + CC_SAFE_DELETE(m_pFontName); + CC_SAFE_DELETE(m_pString); } CCLabelTTF * CCLabelTTF::labelWithString(const char *label, CCSize dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 7798c20663..fcac872dd9 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -577,7 +577,7 @@ namespace cocos2d{ } CCMenuItemToggle::~CCMenuItemToggle() { - m_pSubItems->release(); + CC_SAFE_RELEASE(m_pSubItems); } void CCMenuItemToggle::setSelectedIndex(unsigned int index) { diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index 9f15a88224..e5073907e9 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -88,12 +88,8 @@ bool CCProgressTimer::initWithTexture(cocos2d::CCTexture2D *pTexture) CCProgressTimer::~CCProgressTimer(void) { - if (m_pVertexData) - { - delete[] m_pVertexData; - } - - m_pSprite->release(); + CC_SAFE_DELETE_ARRAY(m_pVertexData); + CC_SAFE_RELEASE(m_pSprite); } void CCProgressTimer::setPercentage(float fPercentage) diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index 7866c3c23f..14db6e74a5 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -60,17 +60,18 @@ public: public: CCDictMaker() + : m_pRootDict(NULL), + m_pCurDict(NULL), + m_tState(SAX_NONE), + m_pArray(NULL), + m_bInArray(false) { - m_pRootDict = NULL; - m_pCurDict = NULL; - m_tState = SAX_NONE; - - m_pArray = NULL; - m_bInArray = false; } + ~CCDictMaker() { } + CCDictionary *dictionaryWithContentsOfFile(const char *pFileName) { CCSAXParser parser; diff --git a/cocos2dx/platform/CCGrid_mobile.cpp b/cocos2dx/platform/CCGrid_mobile.cpp index dafe3499f3..5d78c9bd45 100644 --- a/cocos2dx/platform/CCGrid_mobile.cpp +++ b/cocos2dx/platform/CCGrid_mobile.cpp @@ -326,10 +326,10 @@ namespace cocos2d CCGrid3D::~CCGrid3D(void) { - free(m_pTexCoordinates); - free(m_pVertices); - free(m_pIndices); - free(m_pOriginalVertices); + CC_SAFE_FREE(m_pTexCoordinates); + CC_SAFE_FREE(m_pVertices); + CC_SAFE_FREE(m_pIndices); + CC_SAFE_FREE(m_pOriginalVertices); } void CCGrid3D::blit(void) @@ -461,10 +461,10 @@ namespace cocos2d CCTiledGrid3D::~CCTiledGrid3D(void) { - free(m_pTexCoordinates); - free(m_pVertices); - free(m_pOriginalVertices); - free(m_pIndices); + CC_SAFE_FREE(m_pTexCoordinates); + CC_SAFE_FREE(m_pVertices); + CC_SAFE_FREE(m_pOriginalVertices); + CC_SAFE_FREE(m_pIndices); } CCTiledGrid3D* CCTiledGrid3D::gridWithSize(cocos2d::ccGridSize gridSize, cocos2d::CCTexture2D *pTexture, bool bFlipped) diff --git a/cocos2dx/platform/CCLayer_mobile.cpp b/cocos2dx/platform/CCLayer_mobile.cpp index a5494052df..e2a1811c31 100644 --- a/cocos2dx/platform/CCLayer_mobile.cpp +++ b/cocos2dx/platform/CCLayer_mobile.cpp @@ -303,6 +303,7 @@ bool CCLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) CCLayerColor::CCLayerColor() +: m_cOpacity(0) { } CCLayerColor::~CCLayerColor() @@ -619,11 +620,13 @@ CCPoint CCLayerGradient::getVector() /// MultiplexLayer CCMultiplexLayer::CCMultiplexLayer() +: m_nEnabledLayer(0) +, m_pLayers(NULL) { } CCMultiplexLayer::~CCMultiplexLayer() { - m_pLayers->release(); + CC_SAFE_RELEASE(m_pLayers); } CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...) diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index ad8f7fca28..7ef9526ed5 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -61,7 +61,7 @@ namespace cocos2d CCAnimationCache::~CCAnimationCache() { CCLOGINFO("cocos2d: deallocing %p", this); - m_pAnimations->release(); + CC_SAFE_RELEASE(m_pAnimations); } void CCAnimationCache::addAnimation(CCAnimation *animation, const char * name) diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index a3320976b8..b47afb80cc 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -127,8 +127,8 @@ namespace cocos2d CCSpriteBatchNode::~CCSpriteBatchNode() { - m_pobTextureAtlas->release(); - m_pobDescendants->release(); + CC_SAFE_RELEASE(m_pobTextureAtlas); + CC_SAFE_RELEASE(m_pobDescendants); } // override visit diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index be7f598882..46f1801b90 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -64,8 +64,8 @@ bool CCSpriteFrameCache::init(void) CCSpriteFrameCache::~CCSpriteFrameCache(void) { - m_pSpriteFrames->release(); - m_pSpriteFramesAliases->release(); + CC_SAFE_RELEASE(m_pSpriteFrames); + CC_SAFE_RELEASE(m_pSpriteFramesAliases); } void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary *dictionary, CCTexture2D *pobTexture) diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 3b7bf6b8e9..e7e9ee951a 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -179,8 +179,13 @@ namespace cocos2d { static CCTexture2DPixelFormat g_defaultAlphaPixelFormat = kCCTexture2DPixelFormat_Default; CCTexture2D::CCTexture2D() +: m_uName(0) +, m_bHasPremultipliedAlpha(false) +, m_fMaxS(0.0) +, m_fMaxT(0.0) +, m_uPixelsHigh(0) +, m_uPixelsWide(0) { - m_uName = 0; } CCTexture2D::~CCTexture2D() diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index 769200145d..e5ad23dd51 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -113,11 +113,7 @@ namespace cocos2d { m_pAtlasIndexArray = NULL; } - if( m_pTiles ) - { - delete [] m_pTiles; - m_pTiles = NULL; - } + CC_SAFE_DELETE_ARRAY(m_pTiles); } CCTMXTilesetInfo * CCTMXLayer::getTileSet() { diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 5d9fc48add..cbb1311d80 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -93,15 +93,12 @@ bool CCTouchDispatcher::init(void) CCTouchDispatcher::~CCTouchDispatcher(void) { - m_pTargetedHandlers->release(); - m_pStandardHandlers->release(); - m_pHandlersToAdd->release(); - ccCArrayFree(m_pHandlersToRemove); + CC_SAFE_RELEASE(m_pTargetedHandlers); + CC_SAFE_RELEASE(m_pStandardHandlers); + CC_SAFE_RELEASE(m_pHandlersToAdd); - m_pTargetedHandlers = NULL; - m_pStandardHandlers = NULL; - m_pHandlersToAdd = NULL; - m_pHandlersToRemove = NULL; + ccCArrayFree(m_pHandlersToRemove); + m_pHandlersToRemove = NULL; } // diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.cpp b/cocos2dx/touch_dispatcher/CCTouchHandler.cpp index 92053fce5f..58257ec863 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.cpp @@ -99,7 +99,10 @@ bool CCTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, int nPriority) CCTouchHandler::~CCTouchHandler(void) { - m_pDelegate->destroy(); + if (m_pDelegate) + { + m_pDelegate->destroy(); + } } // implementation of CCStandardTouchHandler @@ -204,6 +207,6 @@ bool CCTargetedTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, int nP CCTargetedTouchHandler::~CCTargetedTouchHandler(void) { - m_pClaimedTouches->release(); + CC_SAFE_RELEASE(m_pClaimedTouches); } }//namespace cocos2d