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 #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

5 comments on commit 11c9871

@bors
Copy link
Contributor

@bors bors commented on 11c9871 Apr 11, 2014

Choose a reason for hiding this comment

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

saw approval from thestinger
at alexcrichton@11c9871

@bors
Copy link
Contributor

@bors bors commented on 11c9871 Apr 11, 2014

Choose a reason for hiding this comment

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

merging alexcrichton/rust/issue-13420 = 11c9871 into auto

@bors
Copy link
Contributor

@bors bors commented on 11c9871 Apr 11, 2014

Choose a reason for hiding this comment

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

alexcrichton/rust/issue-13420 = 11c9871 merged ok, testing candidate = 1b37afe

@bors
Copy link
Contributor

@bors bors commented on 11c9871 Apr 11, 2014

@bors
Copy link
Contributor

@bors bors commented on 11c9871 Apr 11, 2014

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 1b37afe

Please sign in to comment.