Update to latest Rust nightly
This commit is contained in:
parent
25b261975c
commit
8d9133d331
5 changed files with 41 additions and 37 deletions
|
|
@ -5,6 +5,12 @@ use libc;
|
|||
use std::{mem, ptr};
|
||||
use super::ffi;
|
||||
|
||||
fn with_c_str<F, T>(s: &str, f: F) -> T where F: FnOnce(*const i8) -> T {
|
||||
use std::ffi::CString;
|
||||
let c_str = CString::from_slice(s.as_bytes());
|
||||
f(c_str.as_slice_with_nul().as_ptr())
|
||||
}
|
||||
|
||||
pub struct HeadlessContext {
|
||||
context: ffi::OSMesaContext,
|
||||
buffer: Vec<u32>,
|
||||
|
|
@ -41,10 +47,8 @@ impl HeadlessContext {
|
|||
}
|
||||
|
||||
pub fn get_proc_address(&self, addr: &str) -> *const () {
|
||||
use std::c_str::ToCStr;
|
||||
|
||||
unsafe {
|
||||
addr.with_c_str(|s| {
|
||||
with_c_str(addr, |s| {
|
||||
ffi::OSMesaGetProcAddress(mem::transmute(s)) as *const ()
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue