CurtHagenlocher commented on code in PR #547:
URL: https://github.com/apache/arrow-dotnet/pull/547#discussion_r4808937635
##########
src/Apache.Arrow/C/CArrowArrayExporter.cs:
##########
@@ -257,6 +273,25 @@ private unsafe static void ReleaseArray(CArrowArray*
cArray)
cArray->release = default;
}
+ /// <summary>
+ /// Sets the release callback of <paramref name="cArray"/> and
everything under it, once
+ /// conversion has succeeded. Until then nothing refers to the owner,
so a failed export
+ /// leaves nothing for a consumer to release.
+ /// </summary>
+ private unsafe static void SetRelease(ExportedAllocationOwner
sharedOwner, CArrowArray* cArray)
+ {
+ for (long i = 0; i < cArray->n_children; i++)
+ {
+ SetRelease(sharedOwner, cArray->children[i]);
+ }
+ if (cArray->dictionary != null)
+ {
+ SetRelease(sharedOwner, cArray->dictionary);
+ }
+ cArray->private_data = MakePrivateData(sharedOwner);
Review Comment:
Thanks — if setting the release callbacks fails partway, the handles already
made are now freed and the callbacks cleared before the owner is disposed
(`SetReleaseOrUndo`). The tree is complete by then, since conversion has
succeeded. The handles aren't released through the owner's reference count,
because the owner is disposed directly right after.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]