Free a storage block with a size given by `sclass`. This must be a block that was previously allocated by `alloc()` with the same size class.
(&mut self, block: usize, sclass: SizeClass)
| 215 | /// |
| 216 | /// This must be a block that was previously allocated by `alloc()` with the same size class. |
| 217 | fn free(&mut self, block: usize, sclass: SizeClass) { |
| 218 | let sclass = sclass as usize; |
| 219 | |
| 220 | // Make sure we have a free-list head for `sclass`. |
| 221 | if self.free.len() <= sclass { |
| 222 | self.free.resize(sclass + 1, 0); |
| 223 | } |
| 224 | |
| 225 | // Make sure the length field is cleared. |
| 226 | self.data[block] = T::new(0); |
| 227 | // Insert the block on the free list which is a single linked list. |
| 228 | self.data[block + 1] = T::new(self.free[sclass]); |
| 229 | self.free[sclass] = block + 1 |
| 230 | } |
| 231 | |
| 232 | /// Returns two mutable slices representing the two requested blocks. |
| 233 | /// |