diff options
author | Martin Ashby <martin@ashbysoft.com> | 2023-10-19 22:06:57 +0100 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2023-10-19 22:06:57 +0100 |
commit | 8be3275352cad9cad24665115930d18c1cd920fa (patch) | |
tree | 89f15ca4f653eff2d3fe49c0207501c2a792f545 /src/max_allocator.zig | |
parent | bcf6901b8d5acf72c3017f9552892f7bd5a15325 (diff) | |
download | mf-zigtools-8be3275352cad9cad24665115930d18c1cd920fa.tar.gz mf-zigtools-8be3275352cad9cad24665115930d18c1cd920fa.tar.bz2 mf-zigtools-8be3275352cad9cad24665115930d18c1cd920fa.tar.xz mf-zigtools-8be3275352cad9cad24665115930d18c1cd920fa.zip |
Fix test
Diffstat (limited to 'src/max_allocator.zig')
-rw-r--r-- | src/max_allocator.zig | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/max_allocator.zig b/src/max_allocator.zig index 00b8630..8b1f7be 100644 --- a/src/max_allocator.zig +++ b/src/max_allocator.zig @@ -22,7 +22,6 @@ pub const MaxAllocator = struct { var res = self.backing_allocator.rawAlloc(len, ptr_align, ret_addr); if (res != null) { self.currently_allocated += len; - std.log.warn("+{}", .{len}); self.max_allocated = @max(self.currently_allocated, self.max_allocated); } return res; @@ -33,9 +32,7 @@ pub const MaxAllocator = struct { const res = self.backing_allocator.rawResize(buf, buf_align, new_len, ret_addr); if (res) { self.currently_allocated -= buf.len; - std.log.warn("-{}", .{buf.len}); self.currently_allocated += new_len; - std.log.warn("+{}", .{new_len}); self.max_allocated = @max(self.currently_allocated, self.max_allocated); } return res; @@ -45,7 +42,6 @@ pub const MaxAllocator = struct { var self: *@This() = @alignCast(@ptrCast(ctx)); self.backing_allocator.rawFree(buf, buf_align, ret_addr); self.currently_allocated -= buf.len; - std.log.warn("-{}", .{buf.len}); } }; @@ -71,6 +67,7 @@ test { try std.testing.expectEqual(@as(usize, 60), ma.currently_allocated); try std.testing.expect(a.resize(z, 1024)); + z.len = 1024; try std.testing.expectEqual(@as(usize, 1034), ma.max_allocated); try std.testing.expectEqual(@as(usize, 1034), ma.currently_allocated); @@ -78,6 +75,5 @@ test { a.free(z); try std.testing.expectEqual(@as(usize, 1034), ma.max_allocated); - try std.testing.expectEqual(@as(usize, 0), ma.currently_allocated); // works on aarch64, not on x86_64 :thinking-face: - try std.testing.expectEqual(@as(usize, 0), fba.end_index); + try std.testing.expectEqual(@as(usize, 0), ma.currently_allocated); } |