Skip to content

Commit 6eea6c2

Browse files
committed
Merge pull request #90 from bvssvni/master
Moved `MEMORY` to local variable in `Library::init`
2 parents ed8565a + fb0d01d commit 6eea6c2

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/library.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,22 @@ extern "C" fn realloc_library(_memory: ffi::FT_Memory,
3434
}
3535
}
3636

37-
static MEMORY: ffi::FT_MemoryRec = ffi::FT_MemoryRec {
38-
user: 0 as *mut c_void,
39-
alloc: alloc_library,
40-
free: free_library,
41-
realloc: realloc_library,
42-
};
43-
44-
4537
pub struct Library {
4638
raw: ffi::FT_Library,
4739
}
4840

4941
impl Library {
5042
pub fn init() -> FtResult<Library> {
43+
let memory = ffi::FT_MemoryRec {
44+
user: 0 as *mut c_void,
45+
alloc: alloc_library,
46+
free: free_library,
47+
realloc: realloc_library,
48+
};
5149
unsafe {
5250
let mut raw = std::ptr::null_mut();
5351

54-
let err = ffi::FT_New_Library(&MEMORY, &mut raw);
52+
let err = ffi::FT_New_Library(&memory, &mut raw);
5553
if err == ffi::FT_Err_Ok {
5654
ffi::FT_Add_Default_Modules(raw);
5755
Ok(Library {

0 commit comments

Comments
 (0)