freetype-rs icon indicating copy to clipboard operation
freetype-rs copied to clipboard

Avoid `FT_MemoryRec`

Open bvssvni opened this issue 11 years ago • 1 comments

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.

bvssvni avatar Jan 01 '15 17:01 bvssvni

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_memory should go away (it doesn't actually return the memory routines used by that specific Library).
  • Library::new_memory should go away, one can just build a FT_MemoryRec by hand.
  • Library::init should become Library::new and use a hidden static MEMORY plugging into Rust's own memory routines.
  • A new unsafe function Library::new_with_memory should 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.

nox avatar Jul 03 '16 15:07 nox