freetype-rs
freetype-rs copied to clipboard
Avoid `FT_MemoryRec`
See https://github.com/PistonDevelopers/freetype-rs/issues/91#issuecomment-68435558
Alternately, we could avoid dealing with FT_MemoryRec altogether and init FT_Library with FT_Init_Freetype. We don't have to worry about establishing our allocators because rustc links malloc to the proper platform implementation automatically.
I think we should keep it because Rust doesn't actually guarantee the various malloc linking shenanigans.
I think we should do some changes though:
Library::get_memoryshould go away (it doesn't actually return the memory routines used by that specificLibrary).Library::new_memoryshould go away, one can just build aFT_MemoryRecby hand.Library::initshould becomeLibrary::newand use a hidden staticMEMORYplugging into Rust's own memory routines.- A new unsafe function
Library::new_with_memoryshould be introduced to tweak the default routines.
At the very least, the current Library::new_memory method is unsound, because this clearly should be an unsafe operation.