Use std.mem.Allocator.dupe instead of @memcpy.
This commit is contained in:
@@ -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;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user