MATLAB Application Program Interface Reference | Help Desk |
mxDestroyArray
Free dynamic memory allocated by anmxCreate
routine
#include "matrix.h" void mxDestroyArray(mxArray *array_ptr);array_ptr
Pointer to the mxArray
that you want to free.
mxDestroyArray
deallocates the memory occupied by the specified mxArray
. mxDestroyArray
not only deallocates the memory occupied by the mxArray's
characteristics fields (such as m
and n
), but also deallocates all the mxArray's
associated data arrays (such as pr
, pi
, ir
, and/or jc
).
int rows=2, cols=4; double pr_data[] = {5.2, 7.9, 1.3, 4.2, 6.7, 5.9, 1.9, 9.4}; double pi_data[] = {3.4, 6.5, 2.2, 9.1, 8.3, 4.7, 2.5, 7.5}; double *pr, *pi; mxArray *array_ptr; /* Create a 2-by-4 populated complex matrix. */ array_ptr = mxCreateDoubleMatrix(rows, cols, mxCOMPLEX); pr = mxGetPr(array_ptr); pi = mxGetPi(array_ptr); memcpy((void *)pr,(const void *)pr_data, rows*cols*sizeof(double)); memcpy((void *)pi,(const void *)pi_data, rows*cols*sizeof(double)); /* Use the array in some fashion. */ ... /* When finished using the array, deallocate its space. */ mxDestroyArray(array_ptr);For an additional example, see
mxDestroyArray.c
in the mx
subdirectory of the examples
directory.
mxCalloc
, mxFree
, mexMakeArrayPersistent
, mexMakeMemoryPersistent