summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2023-10-19 22:06:57 +0100
committerMartin Ashby <martin@ashbysoft.com>2023-10-19 22:06:57 +0100
commit8be3275352cad9cad24665115930d18c1cd920fa (patch)
tree89f15ca4f653eff2d3fe49c0207501c2a792f545 /src
parentbcf6901b8d5acf72c3017f9552892f7bd5a15325 (diff)
downloadmf-zigtools-main.tar.gz
mf-zigtools-main.tar.bz2
mf-zigtools-main.tar.xz
mf-zigtools-main.zip
Fix build.zig.zonHEADmain
Fix test
Diffstat (limited to 'src')
-rw-r--r--src/max_allocator.zig8
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);
}