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"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669755578,
|
||||
"narHash": "sha256-qmsvMeAsjqF431qX0SjCdvpAZhOKSPvsW+VDnTqTqsE=",
|
||||
"lastModified": 1669849621,
|
||||
"narHash": "sha256-NInJkFlP8exauUs6LE5biAe7gUgw3o1X7JMfKiiVCqw=",
|
||||
"owner": "mitchellh",
|
||||
"repo": "zig-overlay",
|
||||
"rev": "02b5caf310f53ab18ac5749afe3fa517cc52d266",
|
||||
"rev": "9000a1df2473b47bf3a820cf30dc1ecaea85ee8a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -90,58 +90,70 @@ const Impl = struct {
|
||||
}
|
||||
|
||||
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(
|
||||
self: *Self,
|
||||
ctx: *anyopaque,
|
||||
len: usize,
|
||||
ptr_align: u29,
|
||||
len_align: u29,
|
||||
log2_ptr_align: u8,
|
||||
ret_addr: usize,
|
||||
) std.mem.Allocator.Error![]u8 {
|
||||
const result = self.parent.rawAlloc(len, ptr_align, len_align, ret_addr);
|
||||
) ?[*]u8 {
|
||||
const self = @ptrCast(*Self, @alignCast(@alignOf(Self), ctx));
|
||||
const result = self.parent.rawAlloc(len, log2_ptr_align, ret_addr);
|
||||
if (result) |data| {
|
||||
if (data.len != 0) {
|
||||
if (len != 0) {
|
||||
if (name) |n| {
|
||||
allocNamed(data.ptr, data.len, n);
|
||||
allocNamed(data.ptr, len, n);
|
||||
} else {
|
||||
alloc(data.ptr, data.len);
|
||||
alloc(data, len);
|
||||
}
|
||||
}
|
||||
} else |_| {
|
||||
//messageColor("allocation failed", 0xFF0000);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
fn resizeFn(
|
||||
self: *Self,
|
||||
ctx: *anyopaque,
|
||||
buf: []u8,
|
||||
buf_align: u29,
|
||||
log2_buf_align: u8,
|
||||
new_len: usize,
|
||||
len_align: u29,
|
||||
ret_addr: usize,
|
||||
) ?usize {
|
||||
if (self.parent.rawResize(buf, buf_align, new_len, len_align, ret_addr)) |resized_len| {
|
||||
) bool {
|
||||
const self = @ptrCast(*Self, @alignCast(@alignOf(Self), ctx));
|
||||
if (self.parent.rawResize(buf, log2_buf_align, new_len, ret_addr)) {
|
||||
if (name) |n| {
|
||||
freeNamed(buf.ptr, n);
|
||||
allocNamed(buf.ptr, resized_len, n);
|
||||
allocNamed(buf.ptr, new_len, n);
|
||||
} else {
|
||||
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
|
||||
// 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 {
|
||||
self.parent.rawFree(buf, buf_align, ret_addr);
|
||||
fn freeFn(
|
||||
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 (name) |n| {
|
||||
|
Reference in New Issue
Block a user