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 | |
parent | bcf6901b8d5acf72c3017f9552892f7bd5a15325 (diff) | |
download | mf-zigtools-main.tar.gz mf-zigtools-main.tar.bz2 mf-zigtools-main.tar.xz mf-zigtools-main.zip |
Fix test
-rw-r--r-- | build.zig.zon | 3 | ||||
-rw-r--r-- | src/max_allocator.zig | 8 |
2 files changed, 4 insertions, 7 deletions
diff --git a/build.zig.zon b/build.zig.zon index 042c070..d2fd8b1 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,4 +1,5 @@ .{ .name = "mf-zigtools", .version = "0.0.1", -}
\ No newline at end of file + .paths = .{""}, +} 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); } |