Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions bindings/python/src/generate_stubs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ const GeneratedStub = struct {
content: std.ArrayList(u8),
allocator: std.mem.Allocator,

fn init(allocator: std.mem.Allocator) GeneratedStub {
fn init(gpa: std.mem.Allocator) GeneratedStub {
return GeneratedStub{
.content = std.ArrayList(u8).init(allocator),
.allocator = allocator,
.allocator = gpa,
.content = .empty,
};
}

fn deinit(self: *GeneratedStub) void {
self.content.deinit();
self.content.deinit(self.allocator);
}

fn write(self: *GeneratedStub, text: []const u8) !void {
try self.content.appendSlice(text);
try self.content.appendSlice(self.allocator, text);
}

fn writef(self: *GeneratedStub, comptime fmt: []const u8, args: anytype) !void {
try self.content.writer().print(fmt, args);
try self.content.writer(self.allocator).print(fmt, args);
}
};

Expand Down Expand Up @@ -297,8 +297,8 @@ fn generateModuleFunctionsFromMetadata(stub: *GeneratedStub, functions: []const
}

/// Generate complete stub file
fn generateStubFile(allocator: std.mem.Allocator) ![]u8 {
var stub = GeneratedStub.init(allocator);
fn generateStubFile(gpa: std.mem.Allocator) ![]u8 {
var stub = GeneratedStub.init(gpa);
defer stub.deinit();

try stub.write(
Expand Down Expand Up @@ -470,12 +470,12 @@ fn generateStubFile(allocator: std.mem.Allocator) ![]u8 {
try stub.write("\n__version__: str\n");
try stub.write("__all__: list[str]\n");

return try stub.content.toOwnedSlice();
return try stub.content.toOwnedSlice(gpa);
}

/// Generate __init__.pyi stub file for the main package
fn generateInitStub(allocator: std.mem.Allocator) ![]u8 {
var stub = GeneratedStub.init(allocator);
fn generateInitStub(gpa: std.mem.Allocator) ![]u8 {
var stub = GeneratedStub.init(gpa);
defer stub.deinit();

// Header
Expand Down Expand Up @@ -515,7 +515,7 @@ fn generateInitStub(allocator: std.mem.Allocator) ![]u8 {
try stub.write("__version__: str\n");
try stub.write("__all__: list[str]\n");

return try stub.content.toOwnedSlice();
return try stub.content.toOwnedSlice(gpa);
}

/// Main function to generate and write all stub files
Expand Down
6 changes: 3 additions & 3 deletions bindings/python/src/image.zig
Original file line number Diff line number Diff line change
Expand Up @@ -947,11 +947,11 @@ fn image_format(self_obj: ?*c.PyObject, args: ?*c.PyObject) callconv(.c) ?*c.PyO
const formatter = image_ptr.display(display_format);

// Capture formatted output using std.fmt.format
var buffer: std.ArrayList(u8) = .init(allocator);
defer buffer.deinit();
var buffer: std.ArrayList(u8) = .empty;
defer buffer.deinit(allocator);

// Use std.fmt.format to invoke the formatter's format method properly
std.fmt.format(buffer.writer(), "{f}", .{formatter}) catch |err| {
std.fmt.format(buffer.writer(allocator), "{f}", .{formatter}) catch |err| {
switch (err) {
error.OutOfMemory => c.PyErr_SetString(c.PyExc_MemoryError, "Out of memory"),
}
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .zignal,
.version = "0.5.0-dev",
.fingerprint = 0x5303c43db377b63a,
.minimum_zig_version = "0.15.0-dev.1425+7ee6dab39",
.minimum_zig_version = "0.15.0-dev.1519+dd4e25cf4",
.dependencies = .{},
.paths = .{
"build.zig",
Expand Down
2 changes: 1 addition & 1 deletion examples/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .zignal_examples,
.version = "0.0.0",
.fingerprint = 0xcf70e6a9b7002db6,
.minimum_zig_version = "0.15.0-dev.1425+7ee6dab39",
.minimum_zig_version = "0.15.0-dev.1519+dd4e25cf4",
.dependencies = .{
.zignal = .{
.path = "../",
Expand Down
6 changes: 3 additions & 3 deletions examples/src/face_alignment.zig
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ pub export fn extract_aligned_face(
const image: Image(Rgba) = .init(rows, cols, rgba_ptr[0 .. rows * cols]);

const landmarks: []const Point = blk: {
var array: std.ArrayList(Point) = .init(allocator);
array.resize(landmarks_len) catch {
var array: std.ArrayList(Point) = .empty;
array.resize(allocator, landmarks_len) catch {
std.log.err("Ran out of memory while resizing landmarks ArrayList", .{});
@panic("OOM");
};
for (array.items, 0..) |*l, i| {
l.* = landmarks_ptr[i];
}
break :blk array.toOwnedSlice() catch {
break :blk array.toOwnedSlice(allocator) catch {
std.log.err("Ran out of memory while taking ownership of the landmarks ArrayList", .{});
@panic("OOM");
};
Expand Down
Loading