mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix a leak in MacOS thread count function (#34862)
Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
parent
b6a5eaa3db
commit
d252a631d2
2 changed files with 9 additions and 1 deletions
|
@ -56,6 +56,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
#[cfg(not(windows))]
|
||||
panic!("Cross-compiling to windows is currently not supported");
|
||||
} else if target_os == "macos" {
|
||||
println!("cargo:rerun-if-changed=platform/macos/count_threads.c");
|
||||
cc::Build::new()
|
||||
.file("platform/macos/count_threads.c")
|
||||
.compile("count_threads");
|
||||
|
|
|
@ -8,6 +8,13 @@ int macos_count_running_threads() {
|
|||
task_t task = current_task();
|
||||
thread_act_array_t threads;
|
||||
mach_msg_type_number_t tcnt;
|
||||
task_threads(task, &threads, &tcnt);
|
||||
const kern_return_t status = task_threads(task, &threads, &tcnt);
|
||||
if (status == KERN_SUCCESS) {
|
||||
// Free data structures attached to the thread list.
|
||||
for (uint32_t t = 0; t < tcnt; t++) {
|
||||
mach_port_deallocate(task, threads[t]);
|
||||
}
|
||||
vm_deallocate(task, (vm_address_t)threads, sizeof(thread_t) * tcnt);
|
||||
}
|
||||
return tcnt;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue