remove padding
This commit is contained in:
parent
91849c128f
commit
f77d94e624
10
src/user.zig
10
src/user.zig
@ -6,7 +6,6 @@ const Allocator = std.mem.Allocator;
|
||||
const ArrayList = std.ArrayList;
|
||||
const cast = std.math.cast;
|
||||
|
||||
pub const PackedUserSize = @divExact(@bitSizeOf(PackedUser), 8);
|
||||
pub const PackedUser = packed struct {
|
||||
uid: u32,
|
||||
gid: u32,
|
||||
@ -17,7 +16,6 @@ pub const PackedUser = packed struct {
|
||||
name_is_a_suffix: bool,
|
||||
name_len: u5,
|
||||
gecos_len: u8,
|
||||
wip_padding: u8, // https://github.com/ziglang/zig/pull/10941
|
||||
|
||||
// blobSize returns the length of the blob storing string values.
|
||||
pub fn blobLength(self: *const PackedUser) usize {
|
||||
@ -86,7 +84,6 @@ pub const UserWriter = struct {
|
||||
.name_is_a_suffix = std.mem.endsWith(u8, user.home, user.name),
|
||||
.name_len = name_len,
|
||||
.gecos_len = gecos_len,
|
||||
.wip_padding = 0,
|
||||
};
|
||||
|
||||
try self.appendTo.appendSlice(std.mem.asBytes(&puser));
|
||||
@ -130,10 +127,13 @@ pub const UserReader = struct {
|
||||
pub fn next(it: *PackedIterator) ?PackedEntry {
|
||||
if (it.index == it.ur.blob.len) return null;
|
||||
assert(it.index < it.ur.blob.len);
|
||||
const endUser = it.index + PackedUserSize;
|
||||
|
||||
// https://github.com/ziglang/zig/issues/1095
|
||||
const packedUserSizeHere = @sizeOf(PackedUser);
|
||||
const endUser = it.index + packedUserSizeHere;
|
||||
var packedUser = std.mem.bytesAsValue(
|
||||
PackedUser,
|
||||
it.ur.blob[it.index..endUser][0..PackedUserSize],
|
||||
it.ur.blob[it.index..endUser][0..packedUserSizeHere],
|
||||
);
|
||||
const startBlob = endUser + 1;
|
||||
const endBlob = startBlob + packedUser.blobLength();
|
||||
|
Loading…
Reference in New Issue
Block a user