SwitchMapping: eliminate "self" naming convention
This commit is contained in:
parent
82a40725f9
commit
0131d4670d
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user