Commit 06dced4e authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Keep track of the number of fonts on the unused list.

parent d3c12834
......@@ -375,6 +375,7 @@ struct enum_charset_list {
static struct list gdi_font_list = LIST_INIT(gdi_font_list);
static struct list unused_gdi_font_list = LIST_INIT(unused_gdi_font_list);
static unsigned int unused_font_count;
#define UNUSED_CACHE_SIZE 10
static struct list system_links = LIST_INIT(system_links);
......@@ -4307,6 +4308,7 @@ static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const FMAT2 *pma
hflist = HeapAlloc(GetProcessHeap(), 0, sizeof(*hflist));
hflist->hfont = hfont;
list_add_head(&ret->hfontlist, &hflist->entry);
unused_font_count--;
return ret;
}
return NULL;
......@@ -5021,7 +5023,6 @@ BOOL WineEngDestroyFontInstance(HFONT handle)
GdiFont *gdiFont, *next;
HFONTLIST *hflist, *hfnext;
BOOL ret = FALSE;
int i = 0;
GDI_CheckNotLock();
EnterCriticalSection( &freetype_cs );
......@@ -5044,17 +5045,16 @@ BOOL WineEngDestroyFontInstance(HFONT handle)
TRACE("Moving to Unused list\n");
list_remove(&gdiFont->entry);
list_add_head(&unused_gdi_font_list, &gdiFont->entry);
if (unused_font_count > UNUSED_CACHE_SIZE)
{
gdiFont = LIST_ENTRY( list_tail( &unused_gdi_font_list ), struct tagGdiFont, entry );
TRACE("freeing %p\n", gdiFont);
list_remove(&gdiFont->entry);
free_font(gdiFont);
}
else unused_font_count++;
}
}
LIST_FOR_EACH_ENTRY_SAFE( gdiFont, next, &unused_gdi_font_list, struct tagGdiFont, entry )
{
if (i++ < UNUSED_CACHE_SIZE) continue;
TRACE("freeing %p\n", gdiFont);
list_remove(&gdiFont->entry);
free_font(gdiFont);
}
LeaveCriticalSection( &freetype_cs );
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment