Merge pull request #5244 from dumganhar/memory-leak-new-label

closed #3862: [New Label] Memory leak in FontFreeType::createFontAtlas()
This commit is contained in:
James Chen 2014-01-26 06:06:45 -08:00
commit 2c4faeefe0
4 changed files with 8 additions and 6 deletions

View File

@ -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); unsigned short* utf16String = cc_utf8_to_utf16(text);
@ -115,7 +115,7 @@ int Font::getUTF16TextLenght(unsigned short int *text) const
return cc_wcslen(text); return cc_wcslen(text);
} }
unsigned short int * Font::trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const unsigned short * Font::trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const
{ {
if ( newBegin < 0 || newEnd <= 0 ) if ( newBegin < 0 || newEnd <= 0 )
return 0; return 0;

View File

@ -49,8 +49,8 @@ public:
virtual int getFontMaxHeight() const { return 0; } virtual int getFontMaxHeight() const { return 0; }
virtual int getUTF16TextLenght(unsigned short int *text) const; virtual int getUTF16TextLenght(unsigned short int *text) const;
virtual unsigned short int * getUTF16Text(const char *text, int &outNumLetters) const; virtual unsigned short * getUTF16Text(const char *text, int &outNumLetters) const;
virtual unsigned short int * trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const; virtual unsigned short * trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const;
protected: protected:

View File

@ -136,7 +136,9 @@ FontAtlas * FontFreeType::createFontAtlas()
FontAtlas *atlas = new FontAtlas(*this); FontAtlas *atlas = new FontAtlas(*this);
if (_usedGlyphs != GlyphCollection::DYNAMIC) 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(); this->release();
return atlas; return atlas;

View File

@ -1 +1 @@
46dca55d2395fb839c8600236372e35e0f59f016 c5f8d4a3ea721a2ecb36fe381430b7ac6fad1740