Skip to content

Commit 23a3a16

Browse files
committed
---
yaml --- r: 114015 b: refs/heads/master c: 32988db h: refs/heads/master i: 114013: d1eab06 114011: 70bd1c9 114007: 2b66b0f 113999: c99c201 113983: 4239aab v: v3
1 parent 7c0eb6b commit 23a3a16

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f3de28a920b9a9f2b9418b305dfeb30995d2c6d4
2+
refs/heads/master: 32988db2bd82edc92f54c2d32fdcbd748ab78cd4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/libstd/rt/heap.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
// FIXME: #13996: need a way to mark the `allocate` and `reallocate` return values as `noalias`
1313

1414
use intrinsics::{abort, cttz32};
15-
use libc::{c_int, c_void, size_t};
16-
use ptr::RawPtr;
15+
use libc::{c_char, c_int, c_void, size_t};
16+
use ptr::{RawPtr, mut_null, null};
17+
use option::{None, Option};
1718

1819
#[link(name = "jemalloc", kind = "static")]
1920
extern {
@@ -22,6 +23,9 @@ extern {
2223
fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
2324
fn je_dallocx(ptr: *mut c_void, flags: c_int);
2425
fn je_nallocx(size: size_t, flags: c_int) -> size_t;
26+
fn je_malloc_stats_print(write_cb: Option<extern "C" fn(cbopaque: *mut c_void, *c_char)>,
27+
cbopaque: *mut c_void,
28+
opts: *c_char);
2529
}
2630

2731
// -lpthread needs to occur after -ljemalloc, the earlier argument isn't enough
@@ -99,6 +103,16 @@ pub fn usable_size(size: uint, align: uint) -> uint {
99103
unsafe { je_nallocx(size as size_t, mallocx_align(align)) as uint }
100104
}
101105

106+
/// Print implementation-defined allocator statistics.
107+
///
108+
/// These statistics may be inconsistent if other threads use the allocator during the call.
109+
#[unstable]
110+
pub fn stats_print() {
111+
unsafe {
112+
je_malloc_stats_print(None, mut_null(), null())
113+
}
114+
}
115+
102116
/// The allocator for unique pointers.
103117
#[cfg(stage0)]
104118
#[lang="exchange_malloc"]

0 commit comments

Comments
 (0)