| ... | ... | @@ -241,48 +241,3 @@ fn slotSize(class: usize) usize { |
| 241 | 241 | const Log2USize = std.math.Log2Int(usize); |
| 242 | 242 | return @as(usize, 1) << @as(Log2USize, @intCast(class)); |
| 243 | 243 | } |
| 244 | | |
| 245 | | test "large alloc, resize, remap, free" { |
| 246 | | const gpa = std.heap.smp_allocator; |
| 247 | | |
| 248 | | const ptr1 = try gpa.alloc(u64, 42768); |
| 249 | | const ptr2 = try gpa.alloc(u64, 52768); |
| 250 | | gpa.free(ptr1); |
| 251 | | const ptr3 = try gpa.alloc(u64, 62768); |
| 252 | | gpa.free(ptr3); |
| 253 | | gpa.free(ptr2); |
| 254 | | } |
| 255 | | |
| 256 | | test "small allocations - free in same order" { |
| 257 | | const gpa = std.heap.smp_allocator; |
| 258 | | |
| 259 | | var list = std.ArrayList(*u64).init(std.testing.allocator); |
| 260 | | defer list.deinit(); |
| 261 | | |
| 262 | | var i: usize = 0; |
| 263 | | while (i < 513) : (i += 1) { |
| 264 | | const ptr = try gpa.create(u64); |
| 265 | | try list.append(ptr); |
| 266 | | } |
| 267 | | |
| 268 | | for (list.items) |ptr| { |
| 269 | | gpa.destroy(ptr); |
| 270 | | } |
| 271 | | } |
| 272 | | |
| 273 | | test "small allocations - free in reverse order" { |
| 274 | | const gpa = std.heap.smp_allocator; |
| 275 | | |
| 276 | | var list = std.ArrayList(*u64).init(std.testing.allocator); |
| 277 | | defer list.deinit(); |
| 278 | | |
| 279 | | var i: usize = 0; |
| 280 | | while (i < 513) : (i += 1) { |
| 281 | | const ptr = try gpa.create(u64); |
| 282 | | try list.append(ptr); |
| 283 | | } |
| 284 | | |
| 285 | | while (list.popOrNull()) |ptr| { |
| 286 | | gpa.destroy(ptr); |
| 287 | | } |
| 288 | | } |