Skip to content

Commit

Permalink
Initialize and free memory for static analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Jul 1, 2023
1 parent 27b0b4c commit ef51671
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libbrep/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "brep/edit.h"
#include "bu/log.h"
#include "bu/malloc.h"
#include <vector>

void *brep_create()
Expand Down Expand Up @@ -296,23 +297,25 @@ std::vector<ON_3dVector> calculateTangentVectors(const std::vector<ON_3dPoint> &
qk[n + 2] = 2 * qk[n + 1] - qk[n];

/// tk is a middle variable for calculating ak. tk=|qk-1 x qk|
double *tk = new double[n + 3];
double *tk = (double *)bu_calloc(n + 3, sizeof(double), "tk");
tk[0] = ON_CrossProduct(q_, qk[0]).Length();
for (int i = 1; i < n + 3; ++i) {
tk[i] = ON_CrossProduct(qk[i - 1], qk[i]).Length();
}

/// calculate ak
double *ak = new double[n + 1];
double *ak = (double *)bu_calloc(n + 1, sizeof(double), "ak");
for (int i = 0; i < n + 1; ++i) {
ak[i] = tk[i] / (tk[i] + tk[i + 2]);
}
bu_free(tk, "tk");

/// calculate vk
ON_3dVectorArray vk(n + 1);
for (int i = 0; i < n + 1; ++i) {
vk[i] = (1 - ak[i]) * qk[i] + ak[i] * qk[i];
}
bu_free(ak, "ak");

std::vector<ON_3dVector> tangentVectors;

Expand Down

0 comments on commit ef51671

Please sign in to comment.