Skip to content

Commit 7d2ca5d

Browse files
authored
Merge pull request #16 from Isark2/xdo_free_add
Added call to xdo_free on drop to not leak xdo struct and more specifically display
2 parents 7a08702 + 34b9e76 commit 7d2ca5d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/sys/linux.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct Mouse {
3737
#[link(name = "xdo")]
3838
extern "C" {
3939
fn xdo_new(display: *const c_char) -> XDO;
40+
fn xdo_free(xdo: XDO);
4041

4142
fn xdo_move_mouse(xdo: XDO, x: c_int, y: c_int, screen: c_int) -> c_int;
4243
fn xdo_mouse_down(xdo: XDO, window: WINDOW, button: c_int);
@@ -102,3 +103,11 @@ impl Mouse {
102103
Ok(())
103104
}
104105
}
106+
107+
impl Drop for Mouse {
108+
fn drop(&mut self) {
109+
unsafe {
110+
xdo_free(self.xdo);
111+
}
112+
}
113+
}

0 commit comments

Comments
 (0)