MATLAB C matrix interface: does mxDestroyArray recursively destroy elements of cells and structs?

StackOverflow https://stackoverflow.com/questions/14913739

  •  10-03-2022
  •  | 
  •  

Pregunta

The question is in the title: does mxDestroyArray() recursively destroy elements of cells and structs? Is is about MATLAB's C matrix library interface.

To explain in more detail through a concrete example, suppose that I create a 1 by 1 cell using mxCreateCellArray(), then create a numeric matrix using mxCreateNumericArray() and set it as the only element of the cell. Now will calling mxDestroyArray() on the cell destroy the numeric array as well, in one go? Or do I need to call it separately for the numerical array, then the cell? I am hoping for the latter, as this is more reasonable for complex manipulations.

The documentation is ambiguous on this point. Also, it's not easy to devise a test that would give a definitive answer to this.

¿Fue útil?

Solución

According to the reply I got on MATLAB answers, mxDestroyArray() does free elements of cells and structs recursively. Please see that answer for an example program that confirms this.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top