From cc4d1c8ca25038135bedd245430eda73c08fd414 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Tue, 2 Dec 2014 17:15:52 +0100
Subject: [PATCH] dmm: free allocated memory

---
 mex/sources/dmm/designInternal.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mex/sources/dmm/designInternal.cc b/mex/sources/dmm/designInternal.cc
index 23c2e9b2f2..7c4b814766 100644
--- a/mex/sources/dmm/designInternal.cc
+++ b/mex/sources/dmm/designInternal.cc
@@ -44,4 +44,10 @@ void designInternal(int ny, int nz, int nx, int nu, int ns[6], int nt,
   memcpy(a, mxGetPr(lhs[3]), sizeof(double) * mxGetNumberOfElements(lhs[3]));
   memcpy(F, mxGetPr(lhs[4]), sizeof(double) * mxGetNumberOfElements(lhs[4]));
   memcpy(R, mxGetPr(lhs[5]), sizeof(double) * mxGetNumberOfElements(lhs[5]));
+
+  for (int i=0; i<6; i++)
+    {
+      mxDestroyArray(lhs[i]);
+      mxDestroyArray(rhs[i]);
+    }
 }
-- 
GitLab