Fixes memory leaks of freetype.

This commit fixes the issue that freetype library isn’t released in `fonsDeleteInternal()` and causes memory leaks.
This commit is contained in:
Olli Wang 2018-09-27 17:51:38 +08:00
parent fe4ba5f3ba
commit 9b27dc3894

View file

@ -162,11 +162,19 @@ static FT_Library ftLibrary;
int fons__tt_init(FONScontext *context)
{
FT_Error ftError;
FONS_NOTUSED(context);
FONS_NOTUSED(context);
ftError = FT_Init_FreeType(&ftLibrary);
return ftError == 0;
}
int fons__tt_done(FONScontext *context)
{
FT_Error ftError;
FONS_NOTUSED(context);
ftError = FT_Done_FreeType(ftLibrary);
return ftError == 0;
}
int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize)
{
FT_Error ftError;
@ -264,6 +272,11 @@ int fons__tt_init(FONScontext *context)
return 1;
}
int fons__tt_done(FONScontext *context)
FONS_NOTUSED(context);
return 1;
}
int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize)
{
int stbError;
@ -1630,6 +1643,7 @@ void fonsDeleteInternal(FONScontext* stash)
if (stash->texData) free(stash->texData);
if (stash->scratch) free(stash->scratch);
free(stash);
fons__tt_done(stash);
}
void fonsSetErrorCallback(FONScontext* stash, void (*callback)(void* uptr, int error, int val), void* uptr)