From 103fecf3ef47e0235d563108de750c875f859e8c Mon Sep 17 00:00:00 2001 From: pipu Date: Mon, 19 Jan 2015 11:45:20 +0800 Subject: [PATCH 1/2] Fixes memory leaks of using FileUtils::getInstance()->getFileData() in FlatBuffersSerialize.cpp. --- cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp index b75d0a671b..6e0684fd3e 100644 --- a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp +++ b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp @@ -150,8 +150,8 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str return ".csd file doesn not exists "; } - ssize_t size; - std::string content =(char*)FileUtils::getInstance()->getFileData(inFullpath, "r", &size); + std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath); + FileUtils::getInstance()->purgeCachedEntries(); // xml parse tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); @@ -1124,8 +1124,8 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato // CCLOG(".csd file doesn not exists "); } - ssize_t size; - std::string content =(char*)FileUtils::getInstance()->getFileData(inFullpath, "r", &size); + std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath); + FileUtils::getInstance()->purgeCachedEntries(); // xml parse tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); From ea84ae78dc28aac6ed5c1a8aaa68592c600449ce Mon Sep 17 00:00:00 2001 From: pipu Date: Mon, 19 Jan 2015 17:16:26 +0800 Subject: [PATCH 2/2] Invoke FileUtils::getInstance()->getStringFromFile() instead of FileUtils::getInstance()->getFileData(). --- cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp index 6e0684fd3e..f3dfe19d03 100644 --- a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp +++ b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp @@ -151,7 +151,6 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str } std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath); - FileUtils::getInstance()->purgeCachedEntries(); // xml parse tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); @@ -1125,7 +1124,6 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato } std::string content = FileUtils::getInstance()->getStringFromFile(inFullpath); - FileUtils::getInstance()->purgeCachedEntries(); // xml parse tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument();