You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "pitrou (via GitHub)" <gi...@apache.org> on 2023/06/08 17:13:10 UTC
[GitHub] [arrow] pitrou commented on a diff in pull request #35996: GH-35988: [C#] The C data interface implementation can leak on import
pitrou commented on code in PR #35996:
URL: https://github.com/apache/arrow/pull/35996#discussion_r1223336191
##########
csharp/src/Apache.Arrow/C/CArrowArrayImporter.cs:
##########
@@ -90,42 +96,49 @@ public static unsafe RecordBatch ImportRecordBatch(CArrowArray* ptr, Schema sche
private sealed unsafe class ImportedArrowArray : ImportedAllocationOwner
{
- private readonly CArrowArray* _cArray;
+ private readonly CArrowArray _cArray;
public ImportedArrowArray(CArrowArray* cArray)
{
if (cArray == null)
{
throw new ArgumentNullException(nameof(cArray));
}
- _cArray = cArray;
- if (_cArray->release == null)
+ if (cArray->release == null)
{
throw new ArgumentException("Tried to import an array that has already been released.", nameof(cArray));
}
+ _cArray = *cArray;
+ cArray->release = null;
}
protected override void FinalRelease()
{
- if (_cArray->release != null)
+ if (_cArray.release != null)
{
- _cArray->release(_cArray);
+ fixed (CArrowArray* cArray = &_cArray)
+ {
+ cArray->release(cArray);
+ }
Review Comment:
I'm curious, why not simply:
```suggestion
_cArray.release(&_cArray);
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org