lord opened a new issue, #36050:
URL: https://github.com/apache/arrow/issues/36050

   ### Describe the usage question you have. Please include as many useful 
details as  possible.
   
   
   Perhaps my limited C knowledge is making me miss something obvious, but I 
think the producer examples on [this 
page](https://arrow.apache.org/docs/format/CDataInterface.html#exporting-a-struct-float32-utf8-array)
 of the documentation leak memory? Child schemas are malloced:
   
   ```c
    //
    // Initialize child type #0
    //
    child = schema->children[0] = malloc(sizeof(struct ArrowSchema));
   ```
   
   Then in the release implementation, we free the array of child pointers and 
call release on the children array, but don't actually free the child 
ArrowSchema allocations:
   
   ```c
   static void release_malloced_type(struct ArrowSchema* schema) {
      int i;
      for (i = 0; i < schema->n_children; ++i) {
         struct ArrowSchema* child = schema->children[i];
         if (child->release != NULL) {
            child->release(child);
         }
      }
      free(schema->children);
      // Mark released
      schema->release = NULL;
   }
   ```
   
   Since (as far as I can tell?) the docs don't otherwise explicitly state what 
the lifetime of these children is, it could be nice to fix this? Reading the 
C++ ExportArray implementation, it seems like these are in fact freed in the 
release call via the private_data pointer in at least the C++ implementation.
   
   ### Component(s)
   
   C, Documentation


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