Skip to content

Commit 714771e

Browse files
committed
Fixes for functions that take string input paramters
1 parent c48e842 commit 714771e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/graphics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Window {
6767
let mut temp: u64 = 0;
6868
let err_val = af_create_window(&mut temp as MutWndHandle,
6969
width as c_int, height as c_int,
70-
title.as_bytes().as_ptr() as *const u8);
70+
title.clone().as_bytes().as_ptr() as *const u8);
7171
match err_val {
7272
0 => Ok(Window::from(temp)),
7373
_ => Err(AfError::from(err_val)),
@@ -88,7 +88,7 @@ impl Window {
8888
pub fn set_title(&self, title: String) -> Result<(), AfError> {
8989
unsafe {
9090
let err_val = af_set_title(self.handle as WndHandle,
91-
title.as_bytes().as_ptr() as *const u8);
91+
title.clone().as_bytes().as_ptr() as *const u8);
9292
match err_val {
9393
0 => Ok(()),
9494
_ => Err(AfError::from(err_val)),

src/image/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub fn load_image(filename: String, is_color: bool) -> Result<Array, AfError> {
9393
unsafe {
9494
let mut temp: i64 = 0;
9595
let err_val = af_load_image(&mut temp as MutAfArray,
96-
filename.as_bytes().as_ptr() as *const u8,
96+
filename.clone().as_bytes().as_ptr() as *const u8,
9797
is_color as c_int);
9898
match err_val {
9999
0 => Ok(Array::from(temp)),
@@ -105,7 +105,7 @@ pub fn load_image(filename: String, is_color: bool) -> Result<Array, AfError> {
105105
#[allow(unused_mut)]
106106
pub fn save_image(filename: String, input: &Array) -> Result<(), AfError> {
107107
unsafe {
108-
let err_val = af_save_image(filename.as_bytes().as_ptr() as *const u8,
108+
let err_val = af_save_image(filename.clone().as_bytes().as_ptr() as *const u8,
109109
input.get() as AfArray);
110110
match err_val {
111111
0 => Ok(()),

0 commit comments

Comments
 (0)