[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] use of FT_New_Library function
From: |
Lawrence D'Oliveiro |
Subject: |
Re: [ft] use of FT_New_Library function |
Date: |
Sat, 7 Mar 2015 11:14:41 +1300 |
On Fri, 6 Mar 2015 17:34:55 +0100, Martin Štrympl wrote:
> // set library instance with own memory manager
> {
> FT_MemoryRec d_memory;
>
> d_memory.user = ps_pack;
> d_memory.alloc = ESEM_Font_Font_FreeType2_FT_Alloc_Func;
> d_memory.free = ESEM_Font_Font_FreeType2_FT_Free_Func;
> d_memory.realloc = ESEM_Font_Font_FreeType2_FT_Realloc_Func;
>
> d_error = FT_New_Library(&d_memory, &ps_ext->d_library);
> if (d_error!=0)
> {
> break;
> }
>
> FT_Add_Default_Modules(ps_ext->d_library);
> }
>
>
> Can be a problem, that FT_Memory object isn't exist for all time I am
> using the library? I check the documentation of FT_New_Library, but
> there is not written, that I have to keep FT_Memory object in memory.
> But it looks like it can be a problem.
UTSL! From src/base/ftobjs.c:
FT_EXPORT_DEF( FT_Error )
FT_New_Library( FT_Memory memory,
FT_Library *alibrary )
{
...
library->memory = memory;
...
So you see, the FT_Memory object you pass is expected to remain valid
for the life of the FT_Library.