Skip to content

Commit 5925d98

Browse files
committed
Free EMU on exit
1 parent c599eb6 commit 5925d98

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.github/workflows/pypi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
target: ${{ matrix.target }}-unknown-linux-gnu
4444

4545
- name: '🐍 Set up Python'
46+
if: matrix.os != 'ubuntu-latest'
4647
uses: actions/setup-python@v5
4748
with:
4849
python-version: 3.12

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cargo run --example server
4848

4949
`udbserver` provides bindings for several languages:
5050

51-
* [C](bindings/c) (also provides C-compatible API for developing new bindings)
51+
* [C-compatible API](bindings/c)
5252
* [Go](bindings/go)
5353
* [Java](bindings/java)
5454

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ pub fn udbserver<T>(uc: &mut Unicorn<T>, port: u16, start_addr: u64) -> DynResul
4040
uc.add_code_hook(start_addr, start_addr, move |_, _, _| udbserver_start(port).expect("Failed to start udbserver"))
4141
.expect("Failed to add udbserver hook");
4242
}
43-
let emu = emu::Emu::new(unsafe { std::mem::transmute(uc) }, code_hook, mem_hook)?;
43+
let emu = emu::Emu::new(
44+
unsafe { std::mem::transmute::<&mut Unicorn<T>, &'static mut Unicorn<'static, ()>>(uc) },
45+
code_hook,
46+
mem_hook,
47+
)?;
4448
EMU.replace(emu);
4549
if start_addr == 0 {
4650
udbserver_start(port).expect("Failed to start udbserver");
@@ -96,6 +100,7 @@ fn udbserver_loop() -> DynResult<()> {
96100
}
97101

98102
fn handle_disconnect(reason: DisconnectReason) -> DynResult<()> {
103+
EMU.take();
99104
#[cfg(feature = "capi")]
100105
capi::clean();
101106
match reason {

0 commit comments

Comments
 (0)