Skip to content

Commit

Permalink
Use a passed allocator for server.start() for efficiency.
Browse files Browse the repository at this point in the history
  • Loading branch information
Makosai committed Aug 23, 2024
1 parent e2f8466 commit e836e31
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Transport/BaseServer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ pub fn new(allocator: std.mem.Allocator, server_type: ServerType, max_connection
}

//#region Connection Functions
pub fn start(self: *BaseServer) !void {
const allocator = std.heap.page_allocator;
pub fn start(self: *BaseServer, allocator: std.mem.Allocator) !void {
if (Constants.DEBUGGING) {
const header = try std.fmt.allocPrint(allocator, "Starting {s} on Port {d}", .{ self.server_type_name, self.port });
defer allocator.free(header);
Expand Down
2 changes: 1 addition & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ test "create server(s) with gp_allocator" {
var server = try BaseServer.new(allocator, BaseServer.ServerType.MasterServer, 10, 4337);
defer server.deinit(allocator);

try server.start();
try server.start(allocator);
}

print("Finished creating {s} servers.\n", .{fmn});
Expand Down

0 comments on commit e836e31

Please sign in to comment.