Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if unloaded library is last reference.
Browse files Browse the repository at this point in the history
reitermarkus committed Nov 4, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 626e38c commit 7fe5d1d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1672,9 +1672,13 @@ impl Drop for Clang {
{
// Drop the contained reference so the `unload` call below actually
// unloads the the last `libclang` instance.
drop(self.libclang.take());
let libclang = self.libclang.take().unwrap();
let unload = libclang.strong_count() == 1;
drop(libclang);

let _ = clang_sys::unload();
if unload {
let _ = clang_sys::unload();
}
}
}
}

0 comments on commit 7fe5d1d

Please sign in to comment.