diff --git a/Cargo.toml b/Cargo.toml index 84dc0f4..edc6653 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libfmod" -version = "2.222.1" +version = "2.222.2" publish = true edition = "2021" license = "MIT" diff --git a/src/lib.rs b/src/lib.rs index 3f97118..57e651c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -114,14 +114,22 @@ macro_rules! opt_ptr { } macro_rules! to_vec { ($ ptr : expr , $ length : expr , $ closure : expr) => { - slice::from_raw_parts($ptr, $length as usize) - .to_vec() - .into_iter() - .map($closure) - .collect::, Error>>() + if $length == 0 { + Ok(vec![]) + } else { + slice::from_raw_parts($ptr, $length as usize) + .to_vec() + .into_iter() + .map($closure) + .collect::, Error>>() + } }; ($ ptr : expr , $ length : expr) => { - slice::from_raw_parts($ptr, $length as usize).to_vec() + if $length == 0 { + vec![] + } else { + slice::from_raw_parts($ptr, $length as usize).to_vec() + } }; } macro_rules! to_bool { diff --git a/tests/examples/core.rs b/tests/examples/core.rs index 76a6569..c63e34a 100644 --- a/tests/examples/core.rs +++ b/tests/examples/core.rs @@ -7,6 +7,14 @@ use libfmod::ffi::{ }; use libfmod::{DspDescription, DspParameterDesc, DspParameterType, Error, System}; +#[test] +fn test_system_advanced_settings_before_init() -> Result<(), Error> { + let system = System::create()?; + let settings = system.get_advanced_settings()?; + println!("Settings: {:?}", settings); + system.release() +} + #[test] fn test_dsp_custom() -> Result<(), Error> { let system = System::create()?;