Fix memory leak related to freetype, bump v0.3.3

This commit is contained in:
Stephen Seo 2022-08-01 14:30:22 +09:00
parent 09ca5d2bf3
commit a58121741f
4 changed files with 6 additions and 6 deletions

2
Cargo.lock generated
View file

@ -1668,7 +1668,7 @@ dependencies = [
[[package]]
name = "mpd_info_screen"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"bindgen",
"freetype",

View file

@ -1,6 +1,6 @@
[package]
name = "mpd_info_screen"
version = "0.3.2"
version = "0.3.3"
edition = "2018"
description = "Displays info on currently playing music from an MPD daemon"
license = "MIT"

View file

@ -25,7 +25,7 @@ installed already).
# Usage
mpd_info_screen 0.3.2
mpd_info_screen 0.3.3
USAGE:
mpd_info_screen [FLAGS] [OPTIONS] <host> [port]

View file

@ -2,7 +2,7 @@ use std::path::Path;
mod ffi {
use freetype::freetype::{
FT_Done_Face, FT_Done_Library, FT_Face, FT_FaceRec_, FT_Get_Char_Index, FT_Init_FreeType,
FT_Done_Face, FT_Done_FreeType, FT_Face, FT_FaceRec_, FT_Get_Char_Index, FT_Init_FreeType,
FT_Library, FT_ModuleRec_, FT_Open_Args, FT_Open_Face, FT_Parameter_, FT_StreamRec_,
FT_OPEN_PATHNAME,
};
@ -17,7 +17,7 @@ mod ffi {
fn drop(&mut self) {
if !self.library.is_null() {
unsafe {
FT_Done_Library(self.library);
FT_Done_FreeType(self.library);
}
}
}
@ -151,7 +151,7 @@ mod ffi {
}
pub fn font_has_char(c: char, font_path: &Path) -> Result<bool, String> {
let library = ffi::FTLibrary::new().ok_or(String::from("Failed to get FTLibrary"))?;
let library = ffi::FTLibrary::new().ok_or_else(|| String::from("Failed to get FTLibrary"))?;
let mut args = ffi::FTOpenArgs::new_with_path(font_path);
let faces = ffi::FTFaces::new(&library, &mut args)?;