diff --git a/src/models/Property.zig b/src/models/Property.zig index 8404742..39a7553 100644 --- a/src/models/Property.zig +++ b/src/models/Property.zig @@ -51,8 +51,7 @@ pub const Property = struct { .points => |slice| .{ .data = .{ .points = blk: { - const copy = try allocator.alloc(Point2_f, slice.len); - @memcpy(copy, slice); + const copy = try allocator.dupe(Point2_f, slice); break :blk copy; }, }, diff --git a/src/models/shape/shape.zig b/src/models/shape/shape.zig index 9b5ae27..6aef5cd 100644 --- a/src/models/shape/shape.zig +++ b/src/models/shape/shape.zig @@ -15,8 +15,7 @@ fn appendShapeProperties(allocator: std.mem.Allocator, obj: *Object, props: []co for (props) |prop| { if (prop.data == .points) { const pts = prop.data.points; - const copy = try allocator.alloc(Point2_f, pts.len); - @memcpy(copy, pts); + const copy = try allocator.dupe(Point2_f, pts); try obj.properties.append(allocator, .{ .data = .{ .points = copy } }); } else { try obj.properties.append(allocator, prop); diff --git a/src/random_document.zig b/src/random_document.zig index edc60e0..96c37d6 100644 --- a/src/random_document.zig +++ b/src/random_document.zig @@ -84,8 +84,7 @@ fn randomizeObjectProperties(allocator: std.mem.Allocator, doc_size: *const Size x += randFloat(rng, -40, 80); y += randFloat(rng, -30, 60); } - const slice = try allocator.alloc(Point2_f, list.items.len); - @memcpy(slice, list.items); + const slice = try allocator.dupe(Point2_f, list.items); try obj.setProperty(allocator, .{ .data = .{ .points = slice } }); }, } diff --git a/src/ui/canvas_view.zig b/src/ui/canvas_view.zig index e44ec83..4062b5f 100644 --- a/src/ui/canvas_view.zig +++ b/src/ui/canvas_view.zig @@ -676,8 +676,7 @@ fn drawPropertyEditor(canvas: *Canvas, obj: *Document.Object, prop: *const Prope } if (changed) { - const slice = canvas.allocator.alloc(Point2_f, list.items.len) catch return; - @memcpy(slice, list.items); + const slice = canvas.allocator.dupe(Point2_f, list.items) catch return; obj.setProperty(canvas.allocator, .{ .data = .{ .points = slice } }) catch { canvas.allocator.free(slice); return;