From 1a3145b5b6ca43f04ea43e6e3a3718dd9a78aa5c Mon Sep 17 00:00:00 2001 From: Marrub Date: Fri, 29 Mar 2019 14:32:17 -0400 Subject: [PATCH] add null_void --- source/durandal/ffi.rs | 18 ++++++++++++++++++ source/leela/main.rs | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/durandal/ffi.rs b/source/durandal/ffi.rs index 4931034..0bf316c 100644 --- a/source/durandal/ffi.rs +++ b/source/durandal/ffi.rs @@ -9,15 +9,29 @@ macro_rules! c_str { ($s:expr) => {concat!($s, "\0").as_ptr() as $crate::durandal::ffi::NT}; } +#[inline] +pub const fn null_void() -> *const c_void +{ + null() +} + +#[inline] +pub const fn null_mut_void() -> *mut c_void +{ + null_mut() +} + impl CStringVec { /// Creates a new empty CStringVec. + #[inline] pub fn new() -> Self { Self{sv: Vec::new(), cv: vec![null()]} } /// Creates a new `CStringVec` from an iterator. + #[inline] pub fn new_from_iter<'a, I: Iterator>(it: I) -> ResultS { @@ -31,6 +45,7 @@ impl CStringVec } /// Pushes a new `CString`. + #[inline] pub fn push(&mut self, st: CString) { self.cv.insert(self.cv.len() - 1, st.as_ptr()); @@ -38,12 +53,14 @@ impl CStringVec } /// Returns the FFI pointer. + #[inline] pub fn as_ptr(&self) -> *const NT { self.cv.as_ptr() } /// Returns the FFI pointer mutably. + #[inline] pub fn as_mut_ptr(&mut self) -> *mut NT { self.cv.as_mut_ptr() @@ -52,6 +69,7 @@ impl CStringVec impl Default for CStringVec { + #[inline] fn default() -> Self {Self::new()} } diff --git a/source/leela/main.rs b/source/leela/main.rs index 0c326cf..3900c56 100644 --- a/source/leela/main.rs +++ b/source/leela/main.rs @@ -1,6 +1,6 @@ use maraiah::{durandal::{err::*, file::*, image::*, sound::*}, marathon::{machdr, ppm, shp, snd, tga, wad, wav}}; -use std::{fs, io}; +use std::{fs, io, slice::from_ref}; fn make_tga(_opt: &Options, fname: &str, im: &impl Image) -> ResultS<()> { @@ -140,7 +140,7 @@ fn main() -> ResultS<()> macro_rules! arg { ($name:expr, $ref:expr, $type:expr, $desc:expr) => { - ap.refer(&mut $ref).add_option(&[$name], $type, $desc); + ap.refer(&mut $ref).add_option(from_ref(&$name), $type, $desc); }; }