Small cleanup

Rename allocator to gpa (general purpose allocator) and move DebugAllocator type out of main
This commit is contained in:
2025-04-03 11:28:25 -04:00
parent cc94c77cfb
commit 2d1beef44a

View File

@@ -64,13 +64,12 @@ const SaprusMessage = union(SaprusPacketType) {
};
pub fn main() !void {
const DBA = std.heap.DebugAllocator(.{});
var dba: ?DBA = if (comptime is_debug) DBA.init else null;
var dba: ?DebugAllocator = if (comptime is_debug) DebugAllocator.init else null;
defer if (dba) |*d| {
_ = d.deinit();
};
var allocator = if (dba) |*d| d.allocator() else std.heap.smp_allocator;
var gpa = if (dba) |*d| d.allocator() else std.heap.smp_allocator;
const msg = SaprusMessage{
.relay = .{
@@ -79,8 +78,8 @@ pub fn main() !void {
},
};
const msg_bytes = try msg.toBytes(allocator);
defer allocator.free(msg_bytes);
const msg_bytes = try msg.toBytes(gpa);
defer gpa.free(msg_bytes);
try network.init();
defer network.deinit();
@@ -109,5 +108,6 @@ pub fn main() !void {
const builtin = @import("builtin");
const std = @import("std");
const Allocator = std.mem.Allocator;
const DebugAllocator = std.heap.DebugAllocator(.{});
const network = @import("network");