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 {
|
pub fn main() !void {
|
||||||
const DBA = std.heap.DebugAllocator(.{});
|
var dba: ?DebugAllocator = if (comptime is_debug) DebugAllocator.init else null;
|
||||||
var dba: ?DBA = if (comptime is_debug) DBA.init else null;
|
|
||||||
defer if (dba) |*d| {
|
defer if (dba) |*d| {
|
||||||
_ = d.deinit();
|
_ = 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{
|
const msg = SaprusMessage{
|
||||||
.relay = .{
|
.relay = .{
|
||||||
@@ -79,8 +78,8 @@ pub fn main() !void {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const msg_bytes = try msg.toBytes(allocator);
|
const msg_bytes = try msg.toBytes(gpa);
|
||||||
defer allocator.free(msg_bytes);
|
defer gpa.free(msg_bytes);
|
||||||
|
|
||||||
try network.init();
|
try network.init();
|
||||||
defer network.deinit();
|
defer network.deinit();
|
||||||
@@ -109,5 +108,6 @@ pub fn main() !void {
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
const DebugAllocator = std.heap.DebugAllocator(.{});
|
||||||
|
|
||||||
const network = @import("network");
|
const network = @import("network");
|
||||||
|
|||||||
Reference in New Issue
Block a user