-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bindings to all jemalloc public functions
That is, those documented in http://jemalloc.net/jemalloc.3.html For example `malloc` and `free` can be useful when implementing callbacks for a C library that doesn’t provide a size when deallocating: https://www.freetype.org/freetype2/docs/reference/ft2-system_interface.html
- Loading branch information
1 parent
dd5861f
commit e6ea8a9
Showing
3 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "jemalloc-sys" | ||
version = "0.1.3" | ||
version = "0.1.4" | ||
authors = ["Alex Crichton <[email protected]>"] | ||
build = "build.rs" | ||
links = "jemalloc" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![feature(global_allocator)] | ||
|
||
extern crate jemallocator; | ||
extern crate jemalloc_sys; | ||
|
||
// Work around https://github.com/alexcrichton/jemallocator/issues/19 | ||
#[global_allocator] | ||
static A: jemallocator::Jemalloc = jemallocator::Jemalloc; | ||
|
||
#[test] | ||
fn smoke() { | ||
unsafe { | ||
let ptr = jemalloc_sys::malloc(4); | ||
*(ptr as *mut u32) = 0xDECADE; | ||
assert_eq!(*(ptr as *mut u32), 0xDECADE); | ||
jemalloc_sys::free(ptr); | ||
} | ||
} |