Skip to content

Commit

Permalink
fix(allocators): disk memory allocator redundant metadata size
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut committed Nov 25, 2024
1 parent fa70dd7 commit 71f262b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/allocators.zig
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ pub const DiskMemoryAllocator = struct {
// the allocator interface shouldn't allow this (aside from the *Raw methods).
std.debug.assert(alignment <= std.mem.page_size);

const file_aligned_size = alignedFileSize(requested_size + @sizeOf(Metadata));
const file_aligned_size = alignedFileSize(requested_size);
const aligned_mmap_size = alignedMmapSize(file_aligned_size, self.mmap_ratio);

const file_index = self.count.fetchAdd(1, .monotonic);
Expand Down Expand Up @@ -588,8 +588,8 @@ pub const DiskMemoryAllocator = struct {
// the allocator interface shouldn't allow this (aside from the *Raw methods).
std.debug.assert(alignment <= std.mem.page_size);

const old_file_aligned_size = alignedFileSize(buf.len + @sizeOf(Metadata));
const new_file_aligned_size = alignedFileSize(requested_size + @sizeOf(Metadata));
const old_file_aligned_size = alignedFileSize(buf.len);
const new_file_aligned_size = alignedFileSize(requested_size);

if (new_file_aligned_size == old_file_aligned_size) {
return true;
Expand Down Expand Up @@ -642,7 +642,7 @@ pub const DiskMemoryAllocator = struct {
// the allocator interface shouldn't allow this (aside from the *Raw methods).
std.debug.assert(alignment <= std.mem.page_size);

const file_aligned_size = alignedFileSize(buf.len + @sizeOf(Metadata));
const file_aligned_size = alignedFileSize(buf.len);

const buf_ptr: [*]align(std.mem.page_size) u8 = @alignCast(buf.ptr);
const metadata_start = file_aligned_size - @sizeOf(Metadata);
Expand Down

0 comments on commit 71f262b

Please sign in to comment.