Skip to content

Commit

Permalink
replace mem::uninitialized with mem::zeroed
Browse files Browse the repository at this point in the history
The performance difference is probably much to small to justify the use
wildly unsafe and deprecated uninitialized memory...
  • Loading branch information
manuel-rhdt committed Jan 18, 2020
1 parent 35d271e commit 9b2a6d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl GenericBuffer {

pub(crate) fn get_segment_properties(&self) -> SegmentProperties {
unsafe {
let mut segment_props: hb::hb_segment_properties_t = std::mem::uninitialized();
let mut segment_props: hb::hb_segment_properties_t = std::mem::zeroed();
hb::hb_buffer_get_segment_properties(self.as_raw(), &mut segment_props as *mut _);
SegmentProperties::from_raw(segment_props)
}
Expand Down
4 changes: 2 additions & 2 deletions src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl<'a> Font<'a> {

pub fn get_font_v_extents(&self) -> Option<FontExtents> {
unsafe {
let mut extents = std::mem::uninitialized::<FontExtents>();
let mut extents = std::mem::zeroed::<FontExtents>();
let result = hb::hb_font_get_v_extents(
self.as_raw(),
&mut extents as *mut FontExtents as *mut _,
Expand Down Expand Up @@ -369,7 +369,7 @@ impl<'a> Font<'a> {

pub fn get_glyph_extents(&self, glyph: Glyph) -> Option<GlyphExtents> {
unsafe {
let mut extents = std::mem::uninitialized::<GlyphExtents>();
let mut extents = std::mem::zeroed::<GlyphExtents>();
let result = hb::hb_font_get_glyph_extents(self.as_raw(), glyph, &mut extents);
if result == 1 {
Some(extents)
Expand Down

0 comments on commit 9b2a6d9

Please sign in to comment.