()
| 166 | } |
| 167 | #[test] |
| 168 | fn uninitialized_calloc_pool_test() { |
| 169 | |
| 170 | { |
| 171 | let mut calloc_global_buffer = unsafe{define_allocator_memory_pool!(4096, u8, [0; 200 * 1024 * 1024], calloc)}; |
| 172 | let mut ags = CallocAllocatedFreelist4096::<u8>::new_allocator(&mut calloc_global_buffer.data, uninitialized); |
| 173 | { |
| 174 | let mut x = ags.alloc_cell(9999); |
| 175 | x.slice_mut()[0] = 4; |
| 176 | let mut y = ags.alloc_cell(4); |
| 177 | y[0] = 5; |
| 178 | ags.free_cell(y); |
| 179 | |
| 180 | let mut three = ags.alloc_cell(3); |
| 181 | three[0] = 6; |
| 182 | ags.free_cell(three); |
| 183 | |
| 184 | let mut z = ags.alloc_cell(4); |
| 185 | z.slice_mut()[1] = 8; |
| 186 | let mut reget_three = ags.alloc_cell(4); |
| 187 | reget_three.slice_mut()[1] = 9; |
| 188 | //y.mem[0] = 6; // <-- this is an error (use after free) |
| 189 | assert_eq!(x[0], 4); |
| 190 | assert_eq!(z[0], 6); |
| 191 | assert_eq!(z[1], 8); |
| 192 | assert_eq!(reget_three[0], 0); // since we have control over this buffer and the free strategy: this should be zero |
| 193 | assert_eq!(reget_three[1], 9); |
| 194 | let mut _z = ags.alloc_cell(1); |
| 195 | } |
| 196 | println!("{:?}", ags.free_list_start); |
| 197 | } |
| 198 | } |
| 199 | #[test] |
| 200 | fn uninitialized_global_pool_test() { |
| 201 | { |
nothing calls this directly
no test coverage detected