diff --git a/src/batteryinfo.zig b/src/batteryinfo.zig index 94d0806..9e36fa6 100644 --- a/src/batteryinfo.zig +++ b/src/batteryinfo.zig @@ -6,7 +6,7 @@ pub const BatteryInfo = struct { Manufacturer: []u8, Model: []u8, Technology: []u8, - Status: []u8, + Status: []u8, CellSeriesCount: u32 = 0, Capacity: u32 = 0, CapacityDesign: u32 = 0, @@ -22,15 +22,15 @@ pub const BatteryInfo = struct { self._allocator.free(self.Manufacturer); self._allocator.free(self.Model); self._allocator.free(self.Technology); - self._allocator.free(self.Status); + self._allocator.free(self.Status); } }; fn _readInfo(allocator: std.mem.Allocator, dir: std.fs.Dir, path: []const u8) ![]u8 { const start = try dir.readFileAlloc(allocator, path, _maxRead); - defer allocator.free(start); - const trimmed = std.mem.trim(u8, start, "\r\n\t "); - return allocator.dupe(u8, trimmed); + defer allocator.free(start); + const trimmed = std.mem.trim(u8, start, "\r\n\t "); + return allocator.dupe(u8, trimmed); } fn _readInfoU32(allocator: std.mem.Allocator, dir: std.fs.Dir, path: []const u8) !u32 { @@ -43,13 +43,13 @@ pub fn GetBatteryInfoAlloc(allocator: std.mem.Allocator, dir: std.fs.Dir) !Batte const manufacturer = try _readInfo(allocator, dir, "manufacturer"); const model = try _readInfo(allocator, dir, "model_name"); const technology = try _readInfo(allocator, dir, "technology"); - const status = try _readInfo(allocator, dir, "status"); + const status = try _readInfo(allocator, dir, "status"); var info = BatteryInfo{ .Manufacturer = manufacturer, .Model = model, .Technology = technology, - .Status = status, + .Status = status, ._allocator = allocator, };