terminal: fix uninitialized memory in Cell init
parent
3ce043123b
commit
be51f3e729
|
|
@ -2043,10 +2043,13 @@ pub const Cell = packed struct(u64) {
|
||||||
|
|
||||||
/// Helper to make a cell that just has a codepoint.
|
/// Helper to make a cell that just has a codepoint.
|
||||||
pub fn init(cp: u21) Cell {
|
pub fn init(cp: u21) Cell {
|
||||||
return .{
|
// We have to use this bitCast here to ensure that our memory is
|
||||||
.content_tag = .codepoint,
|
// zeroed. Otherwise, the content below will leave some uninitialized
|
||||||
.content = .{ .codepoint = cp },
|
// memory in the packed union. Valgrind verifies this.
|
||||||
};
|
var cell: Cell = @bitCast(@as(u64, 0));
|
||||||
|
cell.content_tag = .codepoint;
|
||||||
|
cell.content = .{ .codepoint = cp };
|
||||||
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn isZero(self: Cell) bool {
|
pub fn isZero(self: Cell) bool {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue