block: only free the descriptor once

This commit is contained in:
Mitchell Hashimoto 2023-10-21 11:22:44 -07:00
parent b8d5546db2
commit 62bcb951b8
No known key found for this signature in database
GPG key ID: 523D5DC389D273BC

View file

@ -107,11 +107,13 @@ pub fn Block(
fn descDisposeHelper(src: *anyopaque) callconv(.C) void { fn descDisposeHelper(src: *anyopaque) callconv(.C) void {
const real_src: *Context = @ptrCast(@alignCast(src)); const real_src: *Context = @ptrCast(@alignCast(src));
inline for (captures_info.fields) |field| { inline for (captures_info.fields) |field| {
if (field.type == objc.c.id) _Block_object_dispose(@field(real_src, field.name), 3); if (field.type == objc.c.id) {
alloc.free(std.mem.sliceTo(@field(@field(real_src, "descriptor"), "signature").?, 0)); _Block_object_dispose(@field(real_src, field.name), 3);
alloc.destroy(@field(real_src, "descriptor"));
} }
} }
alloc.free(std.mem.sliceTo(real_src.descriptor.signature.?, 0));
alloc.destroy(real_src.descriptor);
}
/// Creates a function type for the invocation function, but alters /// Creates a function type for the invocation function, but alters
/// the first arg. The first arg is a pointer so from an ABI perspective /// the first arg. The first arg is a pointer so from an ABI perspective