Skip to content

Commit 898eaf6

Browse files
committed
Replaced variable length arrays with heap allocation
1 parent 7304de9 commit 898eaf6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Consensus.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void Consensus::findConsensus(const vector<Point2f> & points, const vector<int>
151151
std::stable_sort(Z[0], Z[N-1]);
152152

153153
//S are cluster sizes
154-
int S[2*N-1];
154+
int * S = new int[2*N-1];
155155
//TODO: Why does this loop go to 2*N-1? Shouldn't it be simply N? Everything > N gets overwritten later
156156
for(int i = 0; i < 2*N-1; i++)
157157
{
@@ -177,7 +177,7 @@ void Consensus::findConsensus(const vector<Point2f> & points, const vector<int>
177177
}
178178

179179
//Get cluster labels
180-
int T[N];
180+
int * T = new int[N];
181181
for (t_index i = 0; i < N; i++)
182182
{
183183
T[i] = nodes.Find(i);
@@ -208,6 +208,8 @@ void Consensus::findConsensus(const vector<Point2f> & points, const vector<int>
208208
center.y /= points_inlier.size();
209209

210210
delete[] D;
211+
delete[] S;
212+
delete[] T;
211213

212214
FILE_LOG(logDEBUG) << "Consensus::findConsensus() return";
213215
}

0 commit comments

Comments
 (0)