Skip to content

Commit

Permalink
std: Be sure to call pthread_attr_destroy
Browse files Browse the repository at this point in the history
On some OSes (such as freebsd), pthread_attr_init allocates memory, so this is
necessary to deallocate that memory.

Closes rust-lang#13420
  • Loading branch information
alexcrichton committed Apr 11, 2014
1 parent 0156af1 commit 11c9871
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libstd/rt/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ mod imp {
let arg: *libc::c_void = cast::transmute(p);
assert_eq!(pthread_create(&mut native, &attr,
super::thread_start, arg), 0);
assert_eq!(pthread_attr_destroy(&mut attr), 0);
native
}

Expand Down Expand Up @@ -303,6 +304,7 @@ mod imp {
fn pthread_join(native: libc::pthread_t,
value: **libc::c_void) -> libc::c_int;
fn pthread_attr_init(attr: *mut libc::pthread_attr_t) -> libc::c_int;
fn pthread_attr_destroy(attr: *mut libc::pthread_attr_t) -> libc::c_int;
fn pthread_attr_setstacksize(attr: *mut libc::pthread_attr_t,
stack_size: libc::size_t) -> libc::c_int;
fn pthread_attr_setdetachstate(attr: *mut libc::pthread_attr_t,
Expand Down

1 comment on commit 11c9871

@thestinger
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

Please sign in to comment.