diff --git a/examples/allocation_loop/Cargo.lock b/examples/allocation_loop/Cargo.lock new file mode 100644 index 0000000..6a3b08e --- /dev/null +++ b/examples/allocation_loop/Cargo.lock @@ -0,0 +1,23 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "bdwgc-allocator" +version = "0.1.0" +dependencies = [ + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bdwgc-examples" +version = "0.1.0" +dependencies = [ + "bdwgc-allocator 0.1.0", +] + +[[package]] +name = "libc" +version = "0.2.51" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" diff --git a/examples/allocation_loop/Cargo.toml b/examples/allocation_loop/Cargo.toml new file mode 100644 index 0000000..da02720 --- /dev/null +++ b/examples/allocation_loop/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "bdwgc-examples" +version = "0.1.0" +authors = ["Yota Toyama "] +edition = "2018" + +[dependencies] +bdwgc-allocator = { path = "../.." } diff --git a/examples/allocation_loop/src/main.rs b/examples/allocation_loop/src/main.rs new file mode 100644 index 0000000..55c843b --- /dev/null +++ b/examples/allocation_loop/src/main.rs @@ -0,0 +1,17 @@ +extern crate bdwgc_allocator; + +#[global_allocator] +static GLOBAL_ALLOCATOR: bdwgc_allocator::Allocator = bdwgc_allocator::Allocator; + +fn main() { + unsafe { + bdwgc_allocator::Allocator::initialize(); + bdwgc_allocator::Allocator::start_gc(); + } + + let mut _n = bdwgc_allocator::Allocator::alloc(2 ^ 8); + + loop { + _n = bdwgc_allocator::Allocator::alloc(2 ^ 8) + } +}