freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] Accessing `ft_mem_*' from OT-SVG hooks


From: Moazin Khatri
Subject: [ft-devel] Accessing `ft_mem_*' from OT-SVG hooks
Date: Fri, 5 Jul 2019 18:34:18 +0500

Hi,

I'm trying to fix all of the memory leaks in the work that I have
done so far and one very important memory leak is that of the whole
image buffer data.

For example, in my `resvg' port, after the SVG document has been
rendered to a cairo surface, I use `cairo_image_surface_get_data'
to get a pointer to the actual image data and just set the
`slot->bitmap.buffer' to this pointer. This works, but the problem
is freeing this memory later on. All of this memory was allocated
by cairo and the right way to free is by `cairo_surface_destroy'.
But we don't wanna free it immediately, only after the user has
done their thing with the data.

We could solve this by creating another hook that will be triggered
for clearing the surface, but this method is tedious. An easier way
could be to allocate a new memory block by using `FT_Memory', copy
the image data there, free all the cairo resources and set the flag
`FT_GLYPH_OWN_BITMAP' at `slot->internal->flags'. Now, FreeType can
easily handle freeing this memory whenever it wants to.

This approach works fine as long as the client program is linking to
FreeType statically. Turns out, the functions `ft_mem_alloc' and
`ft_mem_free' don't make it to the dynamic symbol table and thus are
not accessible to my rendering port if the client program is linking
dynamically. This is simply because `ft_mem_*' functions are not
exported and cannot be used from outside.

Any ideas on what I should do here? Is it a bad idea to get access
to `ft_mem_*' functions from inside my ports?

Regards,

Moazin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]