Use mxMalloc() and mxFree() over their ANSI C counterparts in order
to register memory usage with the M memory manager (e.g., for Ctrl-C or error purposes).
This commit is contained in:
parent
5cc657c89e
commit
5024034657
@ -5,10 +5,6 @@
|
|||||||
#include "mex.h"
|
#include "mex.h"
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
|
||||||
|
|
||||||
#define MAT_SIZE_T mwSignedIndex
|
|
||||||
|
|
||||||
|
|
||||||
#include "mimetic.h"
|
#include "mimetic.h"
|
||||||
|
|
||||||
|
|
||||||
@ -111,9 +107,9 @@ static void
|
|||||||
deallocate_face_data(int *fneighbour, double *fnormal, double *fcentroid)
|
deallocate_face_data(int *fneighbour, double *fnormal, double *fcentroid)
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
{
|
{
|
||||||
free(fcentroid);
|
mxFree(fcentroid);
|
||||||
free(fnormal);
|
mxFree(fnormal);
|
||||||
free(fneighbour);
|
mxFree(fneighbour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -126,9 +122,9 @@ allocate_face_data(int nfaces, int d, int **fneighbour,
|
|||||||
int *neigh, ret;
|
int *neigh, ret;
|
||||||
double *n, *c;
|
double *n, *c;
|
||||||
|
|
||||||
neigh = malloc(2 * nfaces * sizeof *neigh);
|
neigh = mxMalloc(2 * nfaces * sizeof *neigh);
|
||||||
n = malloc(d * nfaces * sizeof *n);
|
n = mxMalloc(d * nfaces * sizeof *n);
|
||||||
c = malloc(d * nfaces * sizeof *c);
|
c = mxMalloc(d * nfaces * sizeof *c);
|
||||||
|
|
||||||
if ((neigh != NULL) && (n != NULL) && (c != NULL)) {
|
if ((neigh != NULL) && (n != NULL) && (c != NULL)) {
|
||||||
*fneighbour = neigh;
|
*fneighbour = neigh;
|
||||||
@ -259,9 +255,9 @@ static void
|
|||||||
deallocate_cell_data(int *ncfaces, int *cfaces, double *ccentroids)
|
deallocate_cell_data(int *ncfaces, int *cfaces, double *ccentroids)
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
{
|
{
|
||||||
free(ccentroids);
|
mxFree(ccentroids);
|
||||||
free(cfaces);
|
mxFree(cfaces);
|
||||||
free(ncfaces);
|
mxFree(ncfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -274,9 +270,9 @@ allocate_cell_data(int ncells, int d, int ncellfaces,
|
|||||||
int ret, *ncf, *cf;
|
int ret, *ncf, *cf;
|
||||||
double *cc;
|
double *cc;
|
||||||
|
|
||||||
ncf = malloc(ncells * sizeof *ncf);
|
ncf = mxMalloc(ncells * sizeof *ncf);
|
||||||
cf = malloc(ncellfaces * sizeof *cf);
|
cf = mxMalloc(ncellfaces * sizeof *cf);
|
||||||
cc = malloc((ncells * d) * sizeof *cc);
|
cc = mxMalloc((ncells * d) * sizeof *cc);
|
||||||
|
|
||||||
if ((ncf != NULL) && (cf != NULL) && (cc != NULL)) {
|
if ((ncf != NULL) && (cf != NULL) && (cc != NULL)) {
|
||||||
*ncfaces = ncf;
|
*ncfaces = ncf;
|
||||||
@ -468,7 +464,7 @@ static void
|
|||||||
deallocate_perm_data(double *K)
|
deallocate_perm_data(double *K)
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
{
|
{
|
||||||
free(K);
|
mxFree(K);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -480,7 +476,7 @@ allocate_perm_data(int ncells, int d, double **K)
|
|||||||
int ret;
|
int ret;
|
||||||
double *perm;
|
double *perm;
|
||||||
|
|
||||||
perm = malloc(ncells * d * d * sizeof *perm);
|
perm = mxMalloc(ncells * d * d * sizeof *perm);
|
||||||
|
|
||||||
if (perm != NULL) {
|
if (perm != NULL) {
|
||||||
*K = perm;
|
*K = perm;
|
||||||
|
Loading…
Reference in New Issue
Block a user