From 3a3f6bd38581064a147f0c2b229eeb4bc7754311 Mon Sep 17 00:00:00 2001 From: halx99 Date: Fri, 29 Jul 2016 15:27:16 +0800 Subject: [PATCH] #Use Data::takeBuffer replace deep copy data. (#16263) see: https://github.com/EsotericSoftware/spine-runtimes/pull/650 --- cocos/editor-support/spine/spine-cocos2dx.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cocos/editor-support/spine/spine-cocos2dx.cpp b/cocos/editor-support/spine/spine-cocos2dx.cpp index 9ca9d5ea3e..8c55afa502 100644 --- a/cocos/editor-support/spine/spine-cocos2dx.cpp +++ b/cocos/editor-support/spine/spine-cocos2dx.cpp @@ -75,11 +75,8 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) { } char* _spUtil_readFile (const char* path, int* length) { - Data data = FileUtils::getInstance()->getDataFromFile( - FileUtils::getInstance()->fullPathForFilename(path).c_str()); + Data data = FileUtils::getInstance()->getDataFromFile( + FileUtils::getInstance()->fullPathForFilename(path)); if (data.isNull()) return 0; - *length = static_cast(data.getSize()); - char* bytes = MALLOC(char, *length); - memcpy(bytes, data.getBytes(), *length); - return bytes; + return (char*)(data.takeBuffer((ssize_t*)length)); }