aboutsummaryrefslogtreecommitdiffstats
path: root/src/x11
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-04-02 22:04:17 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-04-02 22:41:35 +0200
commitd33c138164d069f025439f97920771f1f8c7775e (patch)
treed54b6953a9540d3b9e93c7a76ac48814be8c9773 /src/x11
parent2e1fe8283f82208375737674a731d2fe3c5e4539 (diff)
downloadglutin-d33c138164d069f025439f97920771f1f8c7775e.tar.gz
glutin-d33c138164d069f025439f97920771f1f8c7775e.zip
Rustup
Diffstat (limited to 'src/x11')
-rw-r--r--src/x11/headless.rs12
-rw-r--r--src/x11/window/mod.rs4
2 files changed, 5 insertions, 11 deletions
diff --git a/src/x11/headless.rs b/src/x11/headless.rs
index e23dfa7..291f04d 100644
--- a/src/x11/headless.rs
+++ b/src/x11/headless.rs
@@ -5,12 +5,6 @@ use libc;
use std::{mem, ptr};
use super::ffi;
-fn with_c_str<F, T>(s: &str, f: F) -> T where F: FnOnce(*const libc::c_char) -> T {
- use std::ffi::CString;
- let c_str = CString::from_slice(s.as_bytes());
- f(c_str.as_ptr())
-}
-
pub struct HeadlessContext {
context: ffi::OSMesaContext,
buffer: Vec<u32>,
@@ -53,9 +47,9 @@ impl HeadlessContext {
pub fn get_proc_address(&self, addr: &str) -> *const () {
unsafe {
- with_c_str(addr, |s| {
- ffi::OSMesaGetProcAddress(mem::transmute(s)) as *const ()
- })
+ use std::ffi::CString;
+ let c_str = CString::new(addr.as_bytes().to_vec()).unwrap();
+ ffi::OSMesaGetProcAddress(mem::transmute(c_str.as_ptr())) as *const ()
}
}
diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs
index 7c93ad3..0188386 100644
--- a/src/x11/window/mod.rs
+++ b/src/x11/window/mod.rs
@@ -39,7 +39,7 @@ fn ensure_thread_init() {
fn with_c_str<F, T>(s: &str, f: F) -> T where F: FnOnce(*const libc::c_char) -> T {
use std::ffi::CString;
- let c_str = CString::from_slice(s.as_bytes());
+ let c_str = CString::new(s.as_bytes().to_vec()).unwrap();
f(c_str.as_ptr())
}
@@ -778,7 +778,7 @@ impl Window {
MouseCursor::AllScroll | MouseCursor::ZoomIn |
MouseCursor::ZoomOut => "left_ptr",
};
- let c_string = CString::from_slice(cursor_name.as_bytes());
+ let c_string = CString::new(cursor_name.as_bytes().to_vec()).unwrap();
let xcursor = ffi::XcursorLibraryLoadCursor(self.x.display, c_string.as_ptr());
ffi::XDefineCursor (self.x.display, self.x.window, xcursor);
ffi::XFlush(self.x.display);