diff --git a/lib/DB.zig b/lib/DB.zig index 78c9462..fa348d5 100644 --- a/lib/DB.zig +++ b/lib/DB.zig @@ -261,7 +261,7 @@ fn getGroup( buf.*[buf_offset + name.len] = 0; return CGroup{ - .name = buf.*[buf_offset .. buf_offset + name.len :0], + .name = buf.*[buf_offset .. buf_offset + name.len].ptr, .gid = group.gid(), .members = member_ptrs, }; @@ -605,7 +605,7 @@ test "high-level API" { const all = try db.getgrnam("all", &buf); try testing.expect(all != null); try testing.expectEqual(all.?.gid, 9999); - try testing.expectEqualStrings(mem.sliceTo(all.?.name, 0), "all"); + try testing.expectEqualStrings(all.?.name[0..3], "all"); const members = all.?.members; try testing.expectEqualStrings(mem.sliceTo(members[0].?, 0), "Name" ** 8); try testing.expectEqualStrings(mem.sliceTo(members[1].?, 0), "root"); @@ -623,7 +623,7 @@ test "high-level API" { const all_gid = try db.getgrgid(9999, &buf); try testing.expect(all_gid != null); try testing.expectEqual(all_gid.?.gid, 9999); - try testing.expectEqualStrings(mem.sliceTo(all_gid.?.name, 0), "all"); + try testing.expectEqualStrings(all_gid.?.name[0..3], "all"); } test "getgr_bufsize" { diff --git a/lib/cgroup.zig b/lib/cgroup.zig index be29dd9..569b123 100644 --- a/lib/cgroup.zig +++ b/lib/cgroup.zig @@ -8,14 +8,14 @@ const meta = @import("std").meta; pub const CGroup = struct { gid: u32, // should be [*:0]const u8 - name: []const u8, + name: [*]const u8, // Should be [*:null]align(1) const ?[*:0]const u8 members: []align(1) const ?[*:0]const u8, pub fn ptr(self: *const CGroup) CGroupPtr { return CGroupPtr{ .gid = self.gid, - .name = self.name.ptr, + .name = self.name, .members = @intToPtr([*]const u8, @ptrToInt(self.members.ptr)), }; }