From edd0e35777223fafaa9a57169c40f6890540c640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 26 Jan 2009 19:25:58 +0000 Subject: [PATCH] The glpyhs stored in a font cache entry were never freed upon deletion of the entry. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29047 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/FontCacheEntry.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/servers/app/FontCacheEntry.cpp b/src/servers/app/FontCacheEntry.cpp index df37b652fb..4567890ffc 100644 --- a/src/servers/app/FontCacheEntry.cpp +++ b/src/servers/app/FontCacheEntry.cpp @@ -49,6 +49,18 @@ class FontCacheEntry::GlyphCachePool { memset(fGlyphs, 0, sizeof(fGlyphs)); } + ~GlyphCachePool() + { + for (int i = 0; i < 256; i++) { + GlyphCache** cache = fGlyphs[i]; + if (cache == NULL) + continue; + for (int j = 0; j < 256; j++) + delete cache[j]; + delete[] cache; + } + } + const GlyphCache* FindGlyph(uint16 glyphCode) const { unsigned msb = (glyphCode >> 8) & 0xFF; @@ -71,12 +83,15 @@ class FontCacheEntry::GlyphCachePool { unsigned lsb = glyphCode & 0xFF; if (fGlyphs[msb][lsb]) - return 0; // already exists, do not overwrite + return NULL; // already exists, do not overwrite GlyphCache* glyph = (GlyphCache*)fAllocator.allocate(sizeof(GlyphCache), sizeof(double)); + if (glyph == NULL) + return NULL; + glyph->glyph_index = glyphIndex; glyph->data = fAllocator.allocate(dataSize); glyph->data_size = dataSize;