From 49eba1bc05f3ff545ac823a60b566d86bc9ffca5 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Tue, 5 Jan 2016 21:29:52 +0100 Subject: [PATCH] Heap allocate drawing buffer On some system it seems that the stack is quite small so now we heap allocate the buffer instead. Also updated the docs and examples using that instead of being on the stack. Bumped version to 0.2.4 Closes #8 --- README.md | 4 ++-- examples/noise.rs | 4 ++-- src/lib.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7789927..59635e9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Usage ```toml # Cargo.toml [dependencies] -minifb = "0.2.3" +minifb = "0.2.4" ``` Example @@ -25,7 +25,7 @@ const WIDTH: usize = 640; const HEIGHT: usize = 360; fn main() { - let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT]; + let mut buffer: Vec = vec![0; WIDTH * HEIGHT]; let mut window = match minifb::Window::new("Test - ESC to exit", WIDTH, HEIGHT, Scale::X1) { Ok(win) => win, diff --git a/examples/noise.rs b/examples/noise.rs index ab39f11..edde38a 100644 --- a/examples/noise.rs +++ b/examples/noise.rs @@ -1,6 +1,6 @@ extern crate minifb; -use minifb::*; +use minifb::{Window, Key, Scale}; const WIDTH: usize = 640; const HEIGHT: usize = 360; @@ -10,7 +10,7 @@ fn main() { let mut carry; let mut seed = 0xbeefu32; - let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT]; + let mut buffer: Vec = vec![0; WIDTH * HEIGHT]; let mut window = match Window::new("Noise Test - Press ESC to exit", WIDTH, HEIGHT, Scale::X2) { Ok(win) => win, diff --git a/src/lib.rs b/src/lib.rs index 2cd143f..51b013b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -183,7 +183,7 @@ use self::os::unix as imp; /// const WIDTH: usize = 640; /// const HEIGHT: usize = 360; /// -/// let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT]; +/// let mut buffer: Vec = vec![0; WIDTH * HEIGHT]; /// /// let mut window = match Window::new("Test - Press ESC to exit", WIDTH, HEIGHT, Scale::X1).unwrap() /// @@ -222,7 +222,7 @@ impl Window { /// # Examples /// /// ```ignore - /// let mut buffer: [u32; 640 * 400] = [0; 640 * 400]; + /// let mut buffer: Vec = vec![0; 640 * 400]; /// /// let mut window = match Window::new("Test", 640, 400, Scale::X1).unwrap(); ///