mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-19 06:38:38 +03:00

* update zig * pkg/fontconfig: clean up @as * pkg/freetype,harfbuzz: clean up @as * pkg/imgui: clean up @as * pkg/macos: clean up @as * pkg/pixman,utf8proc: clean up @as * clean up @as * lots more @as cleanup * undo flatpak changes * clean up @as
31 lines
770 B
Zig
31 lines
770 B
Zig
const std = @import("std");
|
|
const Allocator = std.mem.Allocator;
|
|
const foundation = @import("../foundation.zig");
|
|
const c = @import("c.zig");
|
|
|
|
pub const Data = opaque {
|
|
pub fn createWithBytesNoCopy(data: []const u8) Allocator.Error!*Data {
|
|
return @as(
|
|
?*Data,
|
|
@ptrFromInt(@intFromPtr(c.CFDataCreateWithBytesNoCopy(
|
|
null,
|
|
data.ptr,
|
|
@intCast(data.len),
|
|
c.kCFAllocatorNull,
|
|
))),
|
|
) orelse error.OutOfMemory;
|
|
}
|
|
|
|
pub fn release(self: *Data) void {
|
|
foundation.CFRelease(self);
|
|
}
|
|
};
|
|
|
|
test {
|
|
//const testing = std.testing;
|
|
|
|
var raw = "hello world";
|
|
const data = try Data.createWithBytesNoCopy(raw);
|
|
defer data.release();
|
|
}
|