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
This commit is contained in:
Stephan Aßmus 2009-01-26 19:25:58 +00:00
parent 73476a18af
commit edd0e35777

View File

@ -49,6 +49,18 @@ class FontCacheEntry::GlyphCachePool {
memset(fGlyphs, 0, sizeof(fGlyphs)); 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 const GlyphCache* FindGlyph(uint16 glyphCode) const
{ {
unsigned msb = (glyphCode >> 8) & 0xFF; unsigned msb = (glyphCode >> 8) & 0xFF;
@ -71,12 +83,15 @@ class FontCacheEntry::GlyphCachePool {
unsigned lsb = glyphCode & 0xFF; unsigned lsb = glyphCode & 0xFF;
if (fGlyphs[msb][lsb]) if (fGlyphs[msb][lsb])
return 0; // already exists, do not overwrite return NULL; // already exists, do not overwrite
GlyphCache* glyph GlyphCache* glyph
= (GlyphCache*)fAllocator.allocate(sizeof(GlyphCache), = (GlyphCache*)fAllocator.allocate(sizeof(GlyphCache),
sizeof(double)); sizeof(double));
if (glyph == NULL)
return NULL;
glyph->glyph_index = glyphIndex; glyph->glyph_index = glyphIndex;
glyph->data = fAllocator.allocate(dataSize); glyph->data = fAllocator.allocate(dataSize);
glyph->data_size = dataSize; glyph->data_size = dataSize;