eerhardt commented on code in PR #35996:
URL: https://github.com/apache/arrow/pull/35996#discussion_r1223326388


##########
csharp/src/Apache.Arrow/C/CArrowArrayStreamImporter.cs:
##########
@@ -99,24 +93,17 @@ public ValueTask<RecordBatch> 
ReadNextRecordBatchAsync(CancellationToken cancell
                 }
 
                 RecordBatch result = null;
-                CArrowArray* cArray = CArrowArray.Create();
-                try
+                CArrowArray cArray = new CArrowArray();
+                fixed (CArrowArrayStream* cArrayStream = &_cArrayStream)
                 {
-                    int errno = _cArrayStream->get_next(_cArrayStream, cArray);
+                    int errno = cArrayStream->get_next(cArrayStream, &cArray);
                     if (errno != 0)
                     {
                         throw new Exception($"Unexpected error recieved from 
external stream. Errno: {errno}");
                     }
-                    if (cArray->release != null)
+                    if (cArray.release != null)
                     {
-                        result = CArrowArrayImporter.ImportRecordBatch(cArray, 
_schema);
-                    }
-                }
-                finally
-                {
-                    if (result == null)
-                    {
-                        CArrowArray.Free(cArray);

Review Comment:
   Who is freeing the memory that cArray references now? Or does the 
`RecordBatch` that gets returned take ownership of this memory now?



-- 
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]

Reply via email to