From 29d6a84a8313f9c4f2195dbaa7e68785436a2536 Mon Sep 17 00:00:00 2001 From: flowerinthenight Date: Tue, 24 Sep 2024 01:13:13 +0900 Subject: [PATCH] lib: ci skip: consistent var name --- src/main.zig | 3 ++- src/zgroup.zig | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main.zig b/src/main.zig index 17faddc..463594e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,6 +1,6 @@ const std = @import("std"); -const backoff = @import("zbackoff"); const zgroup = @import("zgroup.zig"); +const backoff = @import("zbackoff"); const log = std.log; @@ -154,6 +154,7 @@ pub fn main() !void { } // We are using curl here as std.http.Client seems to not play well with this endpoint. +// The "seegmed7" in the url is our API key. fn setJoinAddress(allocator: std.mem.Allocator, group: []const u8, addr: []const u8) !void { const enc = std.base64.Base64Encoder.init(std.base64.url_safe_alphabet_chars, '='); const buf = try allocator.alloc(u8, enc.calcSize(addr.len)); diff --git a/src/zgroup.zig b/src/zgroup.zig index 8650438..ad4296a 100644 --- a/src/zgroup.zig +++ b/src/zgroup.zig @@ -227,9 +227,9 @@ pub fn Fleet(UserData: type) type { dst_port: u16, joined: *bool, ) !void { - var parent = std.heap.ArenaAllocator.init(self.allocator); - defer parent.deinit(); // destroy arena in one go - const arena = parent.allocator(); + var aa = std.heap.ArenaAllocator.init(self.allocator); + defer aa.deinit(); // destroy arena in one go + const arena = aa.allocator(); const buf = try arena.alloc(u8, @sizeOf(Message)); const msg: *Message = @ptrCast(@alignCast(buf)); @@ -356,9 +356,9 @@ pub fn Fleet(UserData: type) type { continue; }; - var parent = std.heap.ArenaAllocator.init(self.allocator); - defer parent.deinit(); // destroy arena in one go - const arena = parent.allocator(); + var aa = std.heap.ArenaAllocator.init(self.allocator); + defer aa.deinit(); // destroy arena in one go + const arena = aa.allocator(); switch (msg.isd_cmd) { .infect, @@ -546,9 +546,9 @@ pub fn Fleet(UserData: type) type { fn tick(self: *Self) !void { var i: usize = 0; while (true) : (i += 1) { - var parent = std.heap.ArenaAllocator.init(self.allocator); - defer parent.deinit(); // destroy arena in one go - const arena = parent.allocator(); + var aa = std.heap.ArenaAllocator.init(self.allocator); + defer aa.deinit(); // destroy arena in one go + const arena = aa.allocator(); log.debug("[{d}]", .{i}); // log separator @@ -885,9 +885,9 @@ pub fn Fleet(UserData: type) type { // eg. "127.0.0.1:8080". For pings, we use the src_* payload fields // to identify us, the sender. fn ping(self: *Self, key: []const u8) !bool { - var parent = std.heap.ArenaAllocator.init(self.allocator); - defer parent.deinit(); // destroy arena in one go - const arena = parent.allocator(); + var aa = std.heap.ArenaAllocator.init(self.allocator); + defer aa.deinit(); // destroy arena in one go + const arena = aa.allocator(); const sep = std.mem.indexOf(u8, key, ":") orelse return false; const ip = key[0..sep]; @@ -955,9 +955,9 @@ pub fn Fleet(UserData: type) type { fn indirectPing(args: *IndirectPing) !void { log.debug("[thread] try pinging {s} via {s}", .{ args.dst, args.src }); - var parent = std.heap.ArenaAllocator.init(args.self.allocator); - defer parent.deinit(); // destroy arena in one go - const arena = parent.allocator(); + var aa = std.heap.ArenaAllocator.init(args.self.allocator); + defer aa.deinit(); // destroy arena in one go + const arena = aa.allocator(); const sep = std.mem.indexOf(u8, args.src, ":") orelse return; const ip = args.src[0..sep];