mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
update zig
This commit is contained in:
6
flake.lock
generated
6
flake.lock
generated
@ -109,11 +109,11 @@
|
|||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1669755578,
|
"lastModified": 1669849621,
|
||||||
"narHash": "sha256-qmsvMeAsjqF431qX0SjCdvpAZhOKSPvsW+VDnTqTqsE=",
|
"narHash": "sha256-NInJkFlP8exauUs6LE5biAe7gUgw3o1X7JMfKiiVCqw=",
|
||||||
"owner": "mitchellh",
|
"owner": "mitchellh",
|
||||||
"repo": "zig-overlay",
|
"repo": "zig-overlay",
|
||||||
"rev": "02b5caf310f53ab18ac5749afe3fa517cc52d266",
|
"rev": "9000a1df2473b47bf3a820cf30dc1ecaea85ee8a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -90,58 +90,70 @@ const Impl = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn allocator(self: *Self) std.mem.Allocator {
|
pub fn allocator(self: *Self) std.mem.Allocator {
|
||||||
return std.mem.Allocator.init(self, allocFn, resizeFn, freeFn);
|
return .{
|
||||||
|
.ptr = self,
|
||||||
|
.vtable = &.{
|
||||||
|
.alloc = allocFn,
|
||||||
|
.resize = resizeFn,
|
||||||
|
.free = freeFn,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocFn(
|
fn allocFn(
|
||||||
self: *Self,
|
ctx: *anyopaque,
|
||||||
len: usize,
|
len: usize,
|
||||||
ptr_align: u29,
|
log2_ptr_align: u8,
|
||||||
len_align: u29,
|
|
||||||
ret_addr: usize,
|
ret_addr: usize,
|
||||||
) std.mem.Allocator.Error![]u8 {
|
) ?[*]u8 {
|
||||||
const result = self.parent.rawAlloc(len, ptr_align, len_align, ret_addr);
|
const self = @ptrCast(*Self, @alignCast(@alignOf(Self), ctx));
|
||||||
|
const result = self.parent.rawAlloc(len, log2_ptr_align, ret_addr);
|
||||||
if (result) |data| {
|
if (result) |data| {
|
||||||
if (data.len != 0) {
|
if (len != 0) {
|
||||||
if (name) |n| {
|
if (name) |n| {
|
||||||
allocNamed(data.ptr, data.len, n);
|
allocNamed(data.ptr, len, n);
|
||||||
} else {
|
} else {
|
||||||
alloc(data.ptr, data.len);
|
alloc(data, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else |_| {
|
|
||||||
//messageColor("allocation failed", 0xFF0000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resizeFn(
|
fn resizeFn(
|
||||||
self: *Self,
|
ctx: *anyopaque,
|
||||||
buf: []u8,
|
buf: []u8,
|
||||||
buf_align: u29,
|
log2_buf_align: u8,
|
||||||
new_len: usize,
|
new_len: usize,
|
||||||
len_align: u29,
|
|
||||||
ret_addr: usize,
|
ret_addr: usize,
|
||||||
) ?usize {
|
) bool {
|
||||||
if (self.parent.rawResize(buf, buf_align, new_len, len_align, ret_addr)) |resized_len| {
|
const self = @ptrCast(*Self, @alignCast(@alignOf(Self), ctx));
|
||||||
|
if (self.parent.rawResize(buf, log2_buf_align, new_len, ret_addr)) {
|
||||||
if (name) |n| {
|
if (name) |n| {
|
||||||
freeNamed(buf.ptr, n);
|
freeNamed(buf.ptr, n);
|
||||||
allocNamed(buf.ptr, resized_len, n);
|
allocNamed(buf.ptr, new_len, n);
|
||||||
} else {
|
} else {
|
||||||
free(buf.ptr);
|
free(buf.ptr);
|
||||||
alloc(buf.ptr, resized_len);
|
alloc(buf.ptr, new_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resized_len;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// during normal operation the compiler hits this case thousands of times due to this
|
// during normal operation the compiler hits this case thousands of times due to this
|
||||||
// emitting messages for it is both slow and causes clutter
|
// emitting messages for it is both slow and causes clutter
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn freeFn(self: *Self, buf: []u8, buf_align: u29, ret_addr: usize) void {
|
fn freeFn(
|
||||||
self.parent.rawFree(buf, buf_align, ret_addr);
|
ctx: *anyopaque,
|
||||||
|
buf: []u8,
|
||||||
|
log2_buf_align: u8,
|
||||||
|
ret_addr: usize,
|
||||||
|
) void {
|
||||||
|
const self = @ptrCast(*Self, @alignCast(@alignOf(Self), ctx));
|
||||||
|
self.parent.rawFree(buf, log2_buf_align, ret_addr);
|
||||||
|
|
||||||
if (buf.len != 0) {
|
if (buf.len != 0) {
|
||||||
if (name) |n| {
|
if (name) |n| {
|
||||||
|
Reference in New Issue
Block a user