WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

Commit b7637c46 authored by qinsoon's avatar qinsoon
Browse files

use c string in mu_fastimpl_new_with_opts

parent f79120b2
......@@ -122,14 +122,26 @@ impl MuVM {
*/
#[no_mangle]
pub extern fn mu_fastimpl_new() -> *mut CMuVM {
mu_fastimpl_new_with_opts("")
mu_fastimpl_new_with_opts(ptr::null())
}
#[no_mangle]
pub extern fn mu_fastimpl_new_with_opts(opts: &str) -> *mut CMuVM {
pub extern fn mu_fastimpl_new_with_opts(opts: *const c_char) -> *mut CMuVM {
info!("Creating Mu micro VM fast implementation instance...");
let mvm = Box::new(MuVM::new(opts));
let str_opts = {
if opts == ptr::null() {
""
} else {
let cstr = unsafe {CStr::from_ptr(opts)};
match cstr.to_str() {
Ok(str) => str,
Err(_) => panic!("invalid utf8 string as options: {:?}", cstr)
}
}
};
let mvm = Box::new(MuVM::new(str_opts));
let mvm_ptr = Box::into_raw(mvm);
debug!("The MuVM instance address: {:?}", mvm_ptr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment