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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]