Skip to content

Commit

Permalink
Align the allocations for ChainDb/LinkDb
Browse files Browse the repository at this point in the history
  • Loading branch information
schmee committed Jan 22, 2024
1 parent 9224ab9 commit 4eb6357
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const ChainDb = struct {
var r = self.file.reader();
const stat = try self.file.stat();
// Pre-allocate space for one additional chain
var bytes = try self.allocator.alloc(u8, stat.size + @sizeOf(Chain));
var bytes = try self.allocator.allocWithOptions(u8, stat.size + @sizeOf(Chain), @alignOf(Chain), null);
_ = try r.readAll(bytes);

self.meta = @bitCast(bytes[0..@sizeOf(ChainMeta)].*);
Expand Down Expand Up @@ -283,7 +283,7 @@ const LinkDb = struct {
std.debug.assert(!self.materialized);

const stat = try self.file.stat();
var bytes = try self.allocator.alloc(u8, stat.size + n_chains * @sizeOf(Link));
var bytes = try self.allocator.allocWithOptions(u8, stat.size + n_chains * @sizeOf(Link), @alignOf(Link), null);

try self.file.seekTo(0);
var r = self.file.reader();
Expand Down

0 comments on commit 4eb6357

Please sign in to comment.