From 2ee58c913ce93ff745d8f681b6d072b908d90918 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sun, 26 Jan 2014 20:53:55 +0800 Subject: [PATCH] NewLabel memory leak fix. --- cocos/2d/CCFont.cpp | 2 +- cocos/2d/CCFontFreeType.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCFont.cpp b/cocos/2d/CCFont.cpp index 2f97fe1d76..b45bd0d96e 100644 --- a/cocos/2d/CCFont.cpp +++ b/cocos/2d/CCFont.cpp @@ -99,7 +99,7 @@ const char * Font::getCurrentGlyphCollection() const } } -unsigned short int * Font::getUTF16Text(const char *text, int &outNumLetters) const +unsigned short* Font::getUTF16Text(const char *text, int &outNumLetters) const { unsigned short* utf16String = cc_utf8_to_utf16(text); diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 808d91bf10..dbfdffbb8f 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -136,7 +136,9 @@ FontAtlas * FontFreeType::createFontAtlas() FontAtlas *atlas = new FontAtlas(*this); if (_usedGlyphs != GlyphCollection::DYNAMIC) { - atlas->prepareLetterDefinitions(cc_utf8_to_utf16(getCurrentGlyphCollection())); + unsigned short* utf16 = cc_utf8_to_utf16(getCurrentGlyphCollection()); + atlas->prepareLetterDefinitions(utf16); + CC_SAFE_DELETE_ARRAY(utf16); } this->release(); return atlas;