mirror of
https://git.robbyzambito.me/zaprus
synced 2025-12-20 16:24:50 +00:00
Small cleanup
Rename allocator to gpa (general purpose allocator) and move DebugAllocator type out of main
This commit is contained in:
10
src/main.zig
10
src/main.zig
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user