support allocator api
export FFIs to enable snmalloc being used as a separate allocator https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html
it there a way to trigger the build again?
So on
https://github.com/microsoft/snmalloc/runs/4311202740?check_suite_focus=true
I have a Re-runall checks:
**
I'll hit it for you. Do you need some help with the Windows tests?
Ha, I guess sth interesting is happening on Win. I will have a look later when I can clear some space for MSVC on my PC ;).
Running your test gives:
_STL_ASSERT(_Left == _Right, "containers incompatible for swap");
failing on
std::swap(cloned, moved);
in void test_allocator_vector()
Sure! I am still sorting out the design.
@mjp41 @davidchisnall I begin to wonder whether we should only expose sth like sn_rust_grow, sn_rust_shrink.
I wanted to support sth like:
fn allocator_supports_vector() {
let allocator = SnAllocator::new();
let mut vec = std::vec::Vec::new_in(&allocator);
let mut sum: usize = 0;
for i in 1..512usize {
vec.push(i);
sum += i * i;
}
let res = vec.into_iter().flat_map(|x| {
let mut v = std::vec::Vec::new_in(&allocator);
for _ in 0..x {
v.push(x);
}
v
}).sum();
assert_eq!(sum, res);
}
But I begin to wonder whether it is a bad decision to let user use a Alloc* instead of make Alloc thread_local.