SwitchMapping: eliminate "self" naming convention

This commit is contained in:
Isaac Freund 2024-03-14 13:02:38 +01:00
parent 82a40725f9
commit 0131d4670d
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const Self = @This();
const SwitchMapping = @This();
const Switch = @import("Switch.zig");
const util = @import("util.zig");
@ -27,21 +27,21 @@ pub fn init(
switch_type: Switch.Type,
switch_state: Switch.State,
command_args: []const []const u8,
) !Self {
) !SwitchMapping {
const owned_args = try util.gpa.alloc([:0]u8, command_args.len);
errdefer util.gpa.free(owned_args);
for (command_args, 0..) |arg, i| {
errdefer for (owned_args[0..i]) |a| util.gpa.free(a);
owned_args[i] = try util.gpa.dupeZ(u8, arg);
}
return Self{
return SwitchMapping{
.switch_type = switch_type,
.switch_state = switch_state,
.command_args = owned_args,
};
}
pub fn deinit(self: Self) void {
for (self.command_args) |arg| util.gpa.free(arg);
util.gpa.free(self.command_args);
pub fn deinit(mapping: SwitchMapping) void {
for (mapping.command_args) |arg| util.gpa.free(arg);
util.gpa.free(mapping.command_args);
}