mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-05-30 02:18:57 -06:00
Use std::alloc::alloc
This commit is contained in:
@@ -3,7 +3,7 @@ extern crate coroutine;
|
|||||||
|
|
||||||
use bdwgc_alloc::Allocator;
|
use bdwgc_alloc::Allocator;
|
||||||
use coroutine::asymmetric::Coroutine;
|
use coroutine::asymmetric::Coroutine;
|
||||||
use std::alloc::{GlobalAlloc, Layout};
|
use std::alloc::Layout;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
||||||
@@ -18,7 +18,7 @@ fn main() {
|
|||||||
Allocator::enable_gc();
|
Allocator::enable_gc();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extern crate bdwgc_alloc;
|
extern crate bdwgc_alloc;
|
||||||
|
|
||||||
use bdwgc_alloc::Allocator;
|
use bdwgc_alloc::Allocator;
|
||||||
use std::alloc::{GlobalAlloc, Layout};
|
use std::alloc::Layout;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
||||||
@@ -14,7 +14,7 @@ fn main() {
|
|||||||
unsafe { Allocator::register_current_thread().unwrap() }
|
unsafe { Allocator::register_current_thread().unwrap() }
|
||||||
|
|
||||||
for _ in 0..100 {
|
for _ in 0..100 {
|
||||||
unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { Allocator::unregister_current_thread() }
|
unsafe { Allocator::unregister_current_thread() }
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extern crate bdwgc_alloc;
|
extern crate bdwgc_alloc;
|
||||||
|
|
||||||
use bdwgc_alloc::Allocator;
|
use bdwgc_alloc::Allocator;
|
||||||
use std::alloc::{GlobalAlloc, Layout};
|
use std::alloc::Layout;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
||||||
@@ -10,6 +10,6 @@ fn main() {
|
|||||||
unsafe { Allocator::initialize() }
|
unsafe { Allocator::initialize() }
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extern crate bdwgc_alloc;
|
extern crate bdwgc_alloc;
|
||||||
|
|
||||||
use bdwgc_alloc::Allocator;
|
use bdwgc_alloc::Allocator;
|
||||||
use std::alloc::{GlobalAlloc, Layout};
|
use std::alloc::Layout;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
||||||
@@ -13,7 +13,7 @@ fn main() {
|
|||||||
unsafe { Allocator::register_current_thread().unwrap() }
|
unsafe { Allocator::register_current_thread().unwrap() }
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user