Skip to content

Commit 9c35ce4

Browse files
committed
Use null pointer instead of a pointer to an empty string
1 parent 576fa0e commit 9c35ce4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/graphics.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use defines::{ColorMap, MarkerType};
66
use error::HANDLE_ERROR;
77
use self::libc::{c_int, c_uint, c_float, c_double, c_char};
88
use std::ffi::CString;
9+
use std::ptr;
910

1011
type MutWndHandle = *mut self::libc::c_ulonglong;
1112
type WndHandle = self::libc::c_ulonglong;
@@ -284,7 +285,7 @@ impl Window {
284285
/// - `ylabel` is y axis title
285286
/// - `zlabel` is z axis title
286287
pub fn set_axes_titles(&mut self, xlabel: String, ylabel: String, zlabel: String) {
287-
let cprops = &Cell {row: self.row, col: self.col, title: [0].as_ptr(), cmap: self.cmap};
288+
let cprops = &Cell {row: self.row, col: self.col, title: ptr::null(), cmap: self.cmap};
288289
let xstr = CString::new(xlabel).unwrap();
289290
let ystr = CString::new(ylabel).unwrap();
290291
let zstr = CString::new(zlabel).unwrap();
@@ -314,7 +315,7 @@ impl Window {
314315
/// to next power of 2 and the magnitude remains the same.
315316
pub fn set_axes_limits_compute(&mut self, xrange: &Array, yrange: &Array,
316317
zrange: Option<&Array>, exact: bool) {
317-
let cprops = &Cell {row: self.row, col: self.col, title: [0].as_ptr(), cmap: self.cmap};
318+
let cprops = &Cell {row: self.row, col: self.col, title: ptr::null(), cmap: self.cmap};
318319
unsafe {
319320
let err_val = af_set_axes_limits_compute(self.handle as WndHandle,
320321
xrange.get() as AfArray,
@@ -343,7 +344,7 @@ impl Window {
343344
/// are to extracted. If exact is false then the most significant digit is rounded up
344345
/// to next power of 2 and the magnitude remains the same.
345346
pub fn set_axes_limits_2d(&mut self, xmin: f32, xmax: f32, ymin: f32, ymax: f32, exact: bool) {
346-
let cprops = &Cell {row: self.row, col: self.col, title: [0].as_ptr(), cmap: self.cmap};
347+
let cprops = &Cell {row: self.row, col: self.col, title: ptr::null(), cmap: self.cmap};
347348
unsafe {
348349
let err_val = af_set_axes_limits_2d(self.handle as WndHandle, xmin as c_float,
349350
xmax as c_float, ymin as c_float, ymax as c_float,
@@ -370,7 +371,7 @@ impl Window {
370371
/// to next power of 2 and the magnitude remains the same.
371372
pub fn set_axes_limits_3d(&mut self, xmin: f32, xmax: f32, ymin: f32, ymax: f32,
372373
zmin: f32, zmax: f32, exact: bool) {
373-
let cprops = &Cell {row: self.row, col: self.col, title: [0].as_ptr(), cmap: self.cmap};
374+
let cprops = &Cell {row: self.row, col: self.col, title: ptr::null(), cmap: self.cmap};
374375
unsafe {
375376
let err_val = af_set_axes_limits_3d(self.handle as WndHandle, xmin as c_float,
376377
xmax as c_float, ymin as c_float, ymax as c_float,

0 commit comments

Comments
 (0)