123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- extern crate ralloc;
- mod util;
- use std::ptr;
- #[test]
- fn partial_free() {
- util::multiply(|| {
- let mut alloc = ralloc::Allocator::new();
- let buf = alloc.alloc(63, 3);
- unsafe {
- util::acid(|| {
- ptr::write_bytes(buf, 0, 63);
- *buf = 4;
- });
- util::acid(|| {
- alloc.free(buf.offset(8), 75);
- *buf = 5;
- });
- util::acid(|| {
- alloc.free(buf, 4);
- *buf.offset(4) = 3;
- });
- assert_eq!(*buf.offset(4), 3);
- }
- });
- }
- #[test]
- fn partial_free_double() {
- util::multiply(|| {
- let mut alloc = ralloc::Allocator::new();
- let buf = alloc.alloc(64, 4);
- unsafe {
- util::acid(|| {
- ptr::write_bytes(buf, 0, 64);
- });
- util::acid(|| {
- alloc.free(buf.offset(32), 32);
- *buf = 5;
- });
- assert_eq!(*buf, 5);
- util::acid(|| {
- *buf = 0xAA;
- alloc.free(buf, 32);
- });
- }
- });
- }
|