Skip to content

Commit

Permalink
Merge pull request #23 from duerr-ndt/bufferallocation
Browse files Browse the repository at this point in the history
Fix temporary buffer allocation size.
  • Loading branch information
CihanTopal authored Apr 21, 2021
2 parents a1da6f5 + 2778deb commit 586cfdd
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions EDLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ EDLines::EDLines(Mat srcImage , double _line_error, int _min_line_len, double _


// Temporary buffers used during line fitting
double *x = new double[(width+height) * 8];
double *y = new double[(width+height) * 8];
size_t buffer_size = (width + height) * 8;
for (int segmentNumber = 0; segmentNumber < segmentPoints.size(); segmentNumber++) {
auto segment_size = segmentPoints[segmentNumber].size();
buffer_size = std::max(buffer_size, segment_size);
}
double* x = new double[buffer_size];
double* y = new double[buffer_size];

linesNo = 0;

Expand Down Expand Up @@ -90,8 +95,13 @@ EDLines::EDLines(ED obj, double _line_error, int _min_line_len, double _max_dist


// Temporary buffers used during line fitting
double *x = new double[(width + height) * 8];
double *y = new double[(width + height) * 8];
size_t buffer_size = (width + height) * 8;
for (int segmentNumber = 0; segmentNumber < segmentPoints.size(); segmentNumber++) {
auto segment_size = segmentPoints[segmentNumber].size();
buffer_size = std::max(buffer_size, segment_size);
}
double* x = new double[buffer_size];
double* y = new double[buffer_size];

linesNo = 0;

Expand Down Expand Up @@ -157,8 +167,13 @@ EDLines::EDLines(EDColor obj, double _line_error, int _min_line_len, double _max


// Temporary buffers used during line fitting
double *x = new double[(width + height) * 8];
double *y = new double[(width + height) * 8];
size_t buffer_size = (width + height) * 8;
for (int segmentNumber = 0; segmentNumber < segmentPoints.size(); segmentNumber++) {
auto segment_size = segmentPoints[segmentNumber].size();
buffer_size = std::max(buffer_size, segment_size);
}
double* x = new double[buffer_size];
double* y = new double[buffer_size];

linesNo = 0;

Expand Down

0 comments on commit 586cfdd

Please sign in to comment.