diff options
| author | Marten Ringwelski <git@maringuu.de> | 2020-10-25 09:25:29 +0100 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-10-25 12:22:25 +0100 |
| commit | 16c8752de2a0ff1a2c11914e7fc969e490556a8d (patch) | |
| tree | a7585c503df198fb559155db99e9c2197babb061 | |
| parent | dd92b05af06996ca72b29b056b93258d7999dfe9 (diff) | |
| download | river-16c8752de2a0ff1a2c11914e7fc969e490556a8d.tar.gz river-16c8752de2a0ff1a2c11914e7fc969e490556a8d.tar.xz | |
code: Remove allocator argument from Mapping.init
| -rw-r--r-- | river/Mapping.zig | 16 | ||||
| -rw-r--r-- | river/Mode.zig | 2 | ||||
| -rw-r--r-- | river/command/map.zig | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/river/Mapping.zig b/river/Mapping.zig index c253693..61cfe57 100644 --- a/river/Mapping.zig +++ b/river/Mapping.zig @@ -20,6 +20,7 @@ const Self = @This(); const std = @import("std"); const c = @import("c.zig"); +const util = @import("util.zig"); keysym: c.xkb_keysym_t, modifiers: u32, @@ -29,17 +30,16 @@ command_args: []const []const u8, release: bool, pub fn init( - allocator: *std.mem.Allocator, keysym: c.xkb_keysym_t, modifiers: u32, release: bool, command_args: []const []const u8, ) !Self { - const owned_args = try allocator.alloc([]u8, command_args.len); - errdefer allocator.free(owned_args); + const owned_args = try util.gpa.alloc([]u8, command_args.len); + errdefer util.gpa.free(owned_args); for (command_args) |arg, i| { - errdefer for (owned_args[0..i]) |a| allocator.free(a); - owned_args[i] = try std.mem.dupe(allocator, u8, arg); + errdefer for (owned_args[0..i]) |a| util.gpa.free(a); + owned_args[i] = try std.mem.dupe(util.gpa, u8, arg); } return Self{ .keysym = keysym, @@ -49,7 +49,7 @@ pub fn init( }; } -pub fn deinit(self: Self, allocator: *std.mem.Allocator) void { - for (self.command_args) |arg| allocator.free(arg); - allocator.free(self.command_args); +pub fn deinit(self: Self) void { + for (self.command_args) |arg| util.gpa.free(arg); + util.gpa.free(self.command_args); } diff --git a/river/Mode.zig b/river/Mode.zig index 136e19d..9639c81 100644 --- a/river/Mode.zig +++ b/river/Mode.zig @@ -35,7 +35,7 @@ pub fn init() Self { } pub fn deinit(self: Self) void { - for (self.mappings.items) |m| m.deinit(util.gpa); + for (self.mappings.items) |m| m.deinit(); self.mappings.deinit(); self.pointer_mappings.deinit(); } diff --git a/river/command/map.zig b/river/command/map.zig index e47161e..46b6a8c 100644 --- a/river/command/map.zig +++ b/river/command/map.zig @@ -84,7 +84,7 @@ pub fn map( } } - try mode_mappings.append(try Mapping.init(util.gpa, keysym, modifiers, optionals.release, args[4 + offset ..])); + try mode_mappings.append(try Mapping.init(keysym, modifiers, optionals.release, args[4 + offset ..])); } /// Create a new pointer mapping for a given mode |
