From 2d70e783b3c1fb70c0aa9f4573d23aa3b4376f64 Mon Sep 17 00:00:00 2001 From: Paul Collier Date: Thu, 19 Dec 2013 15:25:22 -0800 Subject: [PATCH 1/3] Relax ~str to &str in shader_source --- gl2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gl2.rs b/gl2.rs index 49bd5fd..ebc23d3 100644 --- a/gl2.rs +++ b/gl2.rs @@ -895,7 +895,7 @@ pub fn scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei) { } } -pub fn shader_source(shader: GLuint, strings: &[~[u8]]) { +pub fn shader_source(shader: GLuint, strings: &[&[u8]]) { unsafe { let pointers = strings.map(|string| (*string).as_ptr()); let lengths = strings.map(|string| string.len() as GLint); From 45e931fa43a8c1a8a8bc0129efa9ab4b97dd51dd Mon Sep 17 00:00:00 2001 From: Paul Collier Date: Thu, 19 Dec 2013 15:27:49 -0800 Subject: [PATCH 2/3] Move most of shader_source out of unsafe{} --- gl2.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gl2.rs b/gl2.rs index ebc23d3..f9abfd3 100644 --- a/gl2.rs +++ b/gl2.rs @@ -896,14 +896,14 @@ pub fn scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei) { } pub fn shader_source(shader: GLuint, strings: &[&[u8]]) { + let pointers = strings.map(|string| (*string).as_ptr()); + let lengths = strings.map(|string| string.len() as GLint); unsafe { - let pointers = strings.map(|string| (*string).as_ptr()); - let lengths = strings.map(|string| string.len() as GLint); glShaderSource(shader, pointers.len() as GLsizei, pointers.as_ptr() as **GLchar, lengths.as_ptr()); - destroy(lengths); - destroy(pointers); } + destroy(lengths); + destroy(pointers); } // FIXME: Does not verify buffer size -- unsafe! From a19177490131265d091b4200dcebd4520ff595f9 Mon Sep 17 00:00:00 2001 From: Paul Collier Date: Thu, 19 Dec 2013 15:30:38 -0800 Subject: [PATCH 3/3] Replace destroy with std drop --- gl2.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gl2.rs b/gl2.rs index f9abfd3..21474ff 100644 --- a/gl2.rs +++ b/gl2.rs @@ -367,13 +367,6 @@ pub type GLsizeiptr = ssize_t; // gl2ext pub type GLeglImageOES = *c_void; -// Helper functions - -pub fn destroy(_x: T) { - // Just let the object drop. -} - - // Exposed Rust API using Rust naming conventions pub fn active_texture(texture: GLenum) { @@ -902,8 +895,8 @@ pub fn shader_source(shader: GLuint, strings: &[&[u8]]) { glShaderSource(shader, pointers.len() as GLsizei, pointers.as_ptr() as **GLchar, lengths.as_ptr()); } - destroy(lengths); - destroy(pointers); + drop(lengths); + drop(pointers); } // FIXME: Does not verify buffer size -- unsafe!