Skip to content

Commit

Permalink
Auto merge of #76 - johshoff:use_stbi_free, r=Ms2ger
Browse files Browse the repository at this point in the history
Use stbi_free instead of libc::free

The current code is correct, but using the free function provided by stb_image
makes it more obvious that it's using the same allocator to allocate and free
memory.
  • Loading branch information
bors-servo committed Jun 23, 2015
2 parents bcf769d + d51f302 commit 2235148
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use stb_image::bindgen::*;

use libc;
use libc::{c_void, c_int};
use std::convert::AsRef;
use std::ffi::CString;
Expand Down Expand Up @@ -51,7 +50,7 @@ fn load_internal<T: Clone>(buf: *mut T, w: c_int, h: c_int, d: c_int) -> Image<T
// FIXME: Shouldn't copy; instead we should use a sendable resource. They
// aren't particularly safe yet though.
let data = slice::from_raw_parts(buf, (w * h * d) as usize).to_vec();
libc::free(buf as *mut c_void);
stbi_image_free(buf as *mut c_void);
Image::<T>{
width : w as usize,
height : h as usize,
Expand Down

0 comments on commit 2235148

Please sign in to comment.