From 73c9707d5d7d83f542a9be2091270bb541c25e46 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 16 Jun 2012 12:48:20 +0800 Subject: [PATCH] CCBIReader fixes + building and running flawless on iOS and Android. Made it works on win32. --- cocos2dx/cocoa/CCString.h | 1 + cocos2dx/extensions/CCBReader/CCBReader.cpp | 15 +- tests/proj.win32/test.win32.vcproj | 134 ++++++++++++------ .../ButtonTest/ButtonTestLayer.h | 6 +- .../HelloCocosBuilderLayer.h | 7 +- .../CocosBuilderTest/MenuTest/MenuTestLayer.h | 6 +- .../TestHeader/TestHeaderLayer.h | 5 +- 7 files changed, 121 insertions(+), 53 deletions(-) diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index 49c619a742..b1d2e55bb8 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -25,6 +25,7 @@ THE SOFTWARE. #define __CCSTRING_H__ #include +#include #include "CCObject.h" NS_CC_BEGIN diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 2a17be97f9..3ad4472939 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -51,7 +51,7 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { } CCBReader::~CCBReader() { - CC_SAFE_DELETE(this->mBytes); + CC_SAFE_DELETE_ARRAY(this->mBytes); this->mCCNodeLoaderLibrary->release(); @@ -104,8 +104,6 @@ CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pC const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath->getCString()); - CC_SAFE_FREE(ccbFullFilePath); - unsigned long size = 0; this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size); @@ -390,15 +388,16 @@ CCString * CCBReader::toLowerCase(CCString * pString) { } CCString * CCBReader::concat(CCString * pStringA, CCString * pStringB) { - int concatenatedLength = pStringA->length() + pStringB->length() + 1; - char concatenated[concatenatedLength]; - + int concatenatedLength = pStringA->length() + pStringB->length(); + char* concatenated = (char*) malloc(concatenatedLength+1); + CCString* pRet = NULL; strcpy(concatenated, pStringA->getCString()); strcat(concatenated, pStringB->getCString()); concatenated[concatenatedLength] = '\0'; - - return CCString::stringWithCString(concatenated); + pRet = CCString::stringWithCString(concatenated); + CC_SAFE_FREE(concatenated); + return pRet; } bool CCBReader::endsWith(CCString * pString, CCString * pEnding) { diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index 3a0a332e6f..b948c75801 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -893,22 +893,6 @@ - - - - - - - - @@ -917,38 +901,106 @@ RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\CocosBuilderTest.h" > - - - + + + + + + + - - + + + + + + + - - + + + + + - - + + + + + + + - - + + + + + - - + + + + + - - - + + + + + + +