Skip to content

Commit

Permalink
Fixes for the ownership-transfer changes (for #124)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwharm committed Sep 21, 2024
1 parent 961982d commit 66ed5f2
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,17 @@ else if (((target instanceof Record record
return;
}

// don't copy the result of ref() or copy()
if ("ref".equals(func.name()) || "copy".equals(func.name())
|| (copyFunc != null && copyFunc.name().equals(func.name()))) {
builder.addNamedCode(PartialStatement.of("var _instance = ")
.add(stmt)
.add(";\n").format(), stmt.arguments());
}

// No copy function, but know memory layout size: malloc() a new
// struct, and copy the contents manually
if (hasMemoryLayout && copyFunc == null) {
else if (hasMemoryLayout && copyFunc == null) {
builder.addStatement("$T _copy = $T.malloc($T.getMemoryLayout().byteSize())",
MemorySegment.class,
ClassNames.GLIB,
Expand Down

0 comments on commit 66ed5f2

Please sign in to comment.