aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2018-10-06 00:32:28 +0200
committerTeddy Wing2018-10-06 00:32:28 +0200
commit60809b7884621cb949eec3ddbe1eae76103d17c2 (patch)
treed22907ae75cd72ee2713af693dff78a20a2ffbc8 /src
parentc231864f9a8c5242d2877ad56f069199082e78b1 (diff)
downloaddome-key-map-60809b7884621cb949eec3ddbe1eae76103d17c2.tar.bz2
c_parse_args(): Box the returned `Config` pointer
Otherwise it gets freed too early by Rust. Add (re-add) a free function for it too now that we know it must be freed manually.
Diffstat (limited to 'src')
-rw-r--r--src/cocoa_bridge.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs
index 2ef4979..70d837a 100644
--- a/src/cocoa_bridge.rs
+++ b/src/cocoa_bridge.rs
@@ -322,7 +322,13 @@ pub extern "C" fn c_parse_args(
let config = config::parse_args(&args);
- &config as *const Config
+ Box::into_raw(Box::new(config))
+}
+
+#[no_mangle]
+pub extern "C" fn config_free(ptr: *mut Config) {
+ if ptr.is_null() { return }
+ unsafe { Box::from_raw(ptr); }
}