-
Notifications
You must be signed in to change notification settings - Fork 1
/
freeFunction.cpp
156 lines (151 loc) · 3.89 KB
/
freeFunction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "spatialsim/freeFunction.h"
#include "spatialsim/mystruct.h"
#include "sbml/SBMLTypes.h"
#include "sbml/extension/SBMLExtensionRegistry.h"
#include "sbml/packages/spatial/extension/SpatialModelPlugin.h"
#include <vector>
using namespace std;
LIBSBML_CPP_NAMESPACE_USE
void freeVarInfo(vector<variableInfo*> &varInfoList)
{
for (size_t i = 0; i < varInfoList.size(); i++) {
variableInfo *info = varInfoList[i];
if (strcmp(info->id, "t") != 0) {
//value
delete[] info->value;
info->value = 0;
//delta
delete[] info->delta;
info->delta = 0;
//Coefficient
delete[] info->diffCInfo;
info->diffCInfo = 0;
delete[] info->adCInfo;
info->adCInfo = 0;
delete[] info->boundaryInfo;
info->boundaryInfo = 0;
//rpinfo
if (info->rpInfo != 0) {
for(unsigned int j = 0; j < info->rpInfo->listNum; j++) {
if(info->rpInfo->constList[j] != 0) {
delete[] info->rpInfo->constList[j];
info->rpInfo->constList[j] = 0;
// } else if(info -> rpInfo -> deltaList[j] != 0) {
// delete[] info -> rpInfo -> deltaList[j];
// info -> rpInfo -> deltaList[j] = 0;
}
}
//varList
delete[] info->rpInfo->varList;
info->rpInfo->varList = 0;
//deltaList
delete[] info->rpInfo->deltaList;
info->rpInfo->deltaList = 0;
//constList
delete[] info->rpInfo->constList;
info->rpInfo->constList = 0;
//opfuncList
delete[] info->rpInfo->opfuncList;
info->rpInfo->opfuncList = 0;
//rpInfo
delete info->rpInfo;
info->rpInfo = 0;
}
//info
delete info;
info = 0;
} else {
delete[] info->id;
info->id = 0;
delete info;
info = 0;
}
}
}
void freeAvolInfo(vector<GeometryInfo*> &geoInfoList)
{
for (size_t i = 0; i < geoInfoList.size(); i++) {
GeometryInfo *geoInfo = geoInfoList[i];
if (geoInfo->rpInfo != 0) {
for(unsigned int j = 0; j < geoInfo->rpInfo->listNum; j++){
if(geoInfo -> rpInfo -> constList[j] != 0) {
delete[] geoInfo -> rpInfo -> constList[j];
geoInfo -> rpInfo -> constList[j] = 0;
}
}
//varList
delete[] geoInfo->rpInfo->varList;
geoInfo->rpInfo->varList = 0;
//deltaList
delete[] geoInfo->rpInfo->deltaList;
geoInfo->rpInfo->deltaList = 0;
//constList
delete[] geoInfo->rpInfo->constList;
geoInfo->rpInfo->constList = 0;
//opfuncList
delete[] geoInfo->rpInfo->opfuncList;
geoInfo->rpInfo->opfuncList = 0;
//rpInfo
delete geoInfo->rpInfo;
geoInfo->rpInfo = 0;
}
//isDomain
delete geoInfo->isDomain;
geoInfo->isDomain = 0;
//isBoundary
delete geoInfo->isBoundary;
geoInfo->isBoundary = 0;
//bType
delete geoInfo->bType;
geoInfo->bType = 0;
//avolinfo
delete geoInfo;
geoInfo = 0;
}
}
void freeRInfo(vector<reactionInfo*> &rInfoList)
{
for (size_t i = 0; i < rInfoList.size(); i++) {
reactionInfo *rInfo = rInfoList[i];
//value
delete[] rInfo->value;
rInfo->value = 0;
if (rInfo->rpInfo != 0) {
//varList
delete[] rInfo->rpInfo->varList;
rInfo->rpInfo->varList = 0;
//deltaList
delete[] rInfo->rpInfo->deltaList;
rInfo->rpInfo->deltaList = 0;
//constList
for(unsigned int j = 0; j < rInfo->rpInfo->listNum; j++) {
if(rInfo->rpInfo->constList[j] != 0) {
delete[] rInfo->rpInfo->constList[j];
rInfo->rpInfo->constList[j] = 0;
}
}
delete[] rInfo->rpInfo->constList;
rInfo->rpInfo->constList = 0;
//opfuncList
delete[] rInfo->rpInfo->opfuncList;
rInfo->rpInfo->opfuncList = 0;
//rpInfo
delete rInfo->rpInfo;
rInfo->rpInfo = 0;
}
//rInfo
delete rInfo;
rInfo = 0;
}
}
void freeBMemInfo(vector<boundaryMembrane*> &bMemInfoList)
{
for (size_t i = 0; i < bMemInfoList.size(); i++) {
boundaryMembrane *info = bMemInfoList[i];
delete[] info->position;
info->position = 0;
//info
delete[] info;
info = 0;
}
}