From 3e9b17e0b9c6e8c8e19400cfee9dea04aa70146b Mon Sep 17 00:00:00 2001 From: Chris Hogan Date: Mon, 19 Feb 2018 09:39:38 -0600 Subject: [PATCH] Fix memory issues --- python/meep.i | 8 ++++---- src/structure.cpp | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/python/meep.i b/python/meep.i index 604b0d85d..93a8a41f7 100644 --- a/python/meep.i +++ b/python/meep.i @@ -395,7 +395,7 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c, if (((material_data *)$1.material)->medium.H_susceptibilities.items) { delete[] ((material_data *)$1.material)->medium.H_susceptibilities.items; } - delete (material_data *)$1.material; + free((material_data *)$1.material); geometric_object_destroy($1); } } @@ -426,7 +426,7 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c, if (((material_data *)$1.items[i].material)->medium.H_susceptibilities.items) { delete[] ((material_data *)$1.items[i].material)->medium.H_susceptibilities.items; } - delete (material_data *)$1.items[i].material; + free((material_data *)$1.items[i].material); geometric_object_destroy($1.items[i]); } delete[] $1.items; @@ -539,7 +539,7 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c, if ($1->medium.H_susceptibilities.items) { delete[] $1->medium.H_susceptibilities.items; } - delete $1; + free($1); } // Typemap suite for array_slice @@ -775,7 +775,7 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c, if ($1.items[i]->medium.H_susceptibilities.items) { delete[] $1.items[i]->medium.H_susceptibilities.items; } - delete $1.items[i]; + free($1.items[i]); } delete[] $1.items; } diff --git a/src/structure.cpp b/src/structure.cpp index 53d813892..722f82157 100644 --- a/src/structure.cpp +++ b/src/structure.cpp @@ -683,6 +683,7 @@ structure_chunk::structure_chunk(const structure_chunk *o) : v(o->v) { FOR_FIELD_TYPES(ft) { { susceptibility *cur = NULL; + chiP[ft] = NULL; for (const susceptibility *ocur = o->chiP[ft]; ocur; ocur = ocur->next) { if (cur) { cur->next = ocur->clone(); cur = cur->next; } else { chiP[ft] = cur = ocur->clone(); }