partial_realloc.rs 539 B

1234567891011121314151617181920212223242526272829
  1. extern crate ralloc;
  2. #[global_allocator]
  3. static ALLOCATOR: ralloc::Allocator = ralloc::Allocator;
  4. mod util;
  5. use std::ptr;
  6. #[test]
  7. fn partial_realloc() {
  8. util::multiply(|| {
  9. let buf = ralloc::alloc(63, 3);
  10. unsafe {
  11. util::acid(|| {
  12. ptr::write_bytes(buf, 0, 63);
  13. *buf = 4;
  14. });
  15. ralloc::realloc(buf.offset(8), 75, 0, 23);
  16. *buf = 5;
  17. *ralloc::realloc(buf, 4, 10, 2) = 10;
  18. ralloc::free(buf, 4);
  19. }
  20. });
  21. }