Skip to content

Commit

Permalink
Bugfix #2402 main_v11.0 sonarqube (First PR) (#2447)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway authored Feb 21, 2023
1 parent beb95b4 commit 04bd3c0
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 633 deletions.
311 changes: 59 additions & 252 deletions src/basic/vx_math/pwl.cc

Large diffs are not rendered by default.

21 changes: 4 additions & 17 deletions src/basic/vx_math/pwl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


#include <iostream>

#include <vector>

////////////////////////////////////////////////////////////////////////

Expand All @@ -39,17 +39,10 @@ class PiecewiseLinear {

protected:

void extend(int);

int N;

int n_alloc;

ConcatString Name;

double * X;
double * Y;

std::vector<double> X;
std::vector<double> Y;

public:

Expand Down Expand Up @@ -95,20 +88,14 @@ class PiecewiseLinear {
////////////////////////////////////////////////////////////////////////


inline int PiecewiseLinear::n_points() const { return ( N ); }
inline int PiecewiseLinear::n_points() const { return ( X.size() ); }

inline const char * PiecewiseLinear::name() const { return ( Name.c_str() ); }


////////////////////////////////////////////////////////////////////////


extern int pwl_interpolate(const double * y, const double * x, int n, double x_in, double & y_out);


////////////////////////////////////////////////////////////////////////


#endif /* __PIECEWISE_LINEAR_H__ */


Expand Down
16 changes: 3 additions & 13 deletions src/basic/vx_util/ascii_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using namespace std;
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <vector>

#include "vx_log.h"
#include "vx_cal.h"
Expand Down Expand Up @@ -1336,21 +1337,14 @@ if ( Nrows < 0 || Nrows >= INT_MAX ) {

if ( Nrows <= 2 ) return;

int * left = new int [Nrows];
int * right = new int [Nrows];
std::vector<int> left (Nrows, 0);
std::vector<int> right(Nrows, 0);

int r, c, n, k;
int max_left, max_right;
const char fill_char = ' ';
const int r_start = 1; // skip the header row


for (r=0; r<Nrows; ++r) {

left[r] = right[r] = 0;

}

for (c=0; c<Ncols; ++c) {

// get the pad size for that column
Expand Down Expand Up @@ -1386,10 +1380,6 @@ for (c=0; c<Ncols; ++c) {
// done
//

if ( left ) { delete [] left; left = 0; }
if ( right ) { delete [] right; right = 0; }


DecimalPointsAligned = true;

return;
Expand Down
83 changes: 12 additions & 71 deletions src/basic/vx_util/crc_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


#include <iostream>
#include <vector>

#include "num_array.h"
#include "int_array.h"
Expand All @@ -34,27 +35,6 @@
static const int crc_array_alloc_inc = 25;


////////////////////////////////////////////////////////////////////////


template <typename T>

int is_bigger(const void * p1, const void * p2)

{

const T & a = *((T *) p1);
const T & b = *((T *) p2);

if ( a < b ) return ( -1 );
if ( a > b ) return ( 1 );

return ( 0 );

}



////////////////////////////////////////////////////////////////////////


Expand All @@ -69,7 +49,7 @@ class CRC_Array {
void assign(const CRC_Array &);


T * e;
std::vector<T> e;

int Nelements;

Expand Down Expand Up @@ -144,12 +124,6 @@ class CRC_Array {
};


////////////////////////////////////////////////////////////////////////


// static int is_bigger(const void *, const void *);


////////////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -205,8 +179,6 @@ void CRC_Array<T>::init_from_scratch()

{

e = (T *) 0;

clear();

return;
Expand All @@ -223,7 +195,7 @@ void CRC_Array<T>::clear()

{

if ( e ) { delete [] e; e = (T *) 0; }
e.clear();

Nelements = Nalloc = 0;

Expand All @@ -247,13 +219,7 @@ if ( a.Nelements == 0 ) return;

extend(a.Nelements);

int j;

for (j=0; j<(a.Nelements); ++j) {

e[j] = a.e[j];

}
e = a.e;

Nelements = a.Nelements;

Expand Down Expand Up @@ -286,36 +252,7 @@ if ( ! exact ) {

}

T * u = (T *) 0;

u = new T [len];

if ( !u ) {

mlog << Error << "\nvoid CRC_Array::extend(int, bool) -> "
<< "memory allocation error\n\n";

exit ( 1 );

}

int j;

memset(u, 0, len*sizeof(T));

if ( e ) {

for (j=0; j<Nelements; ++j) {

u[j] = e[j];

}

delete [] e; e = (T *) 0;

}

e = u; u = (T *) 0;
e.reserve( len );

Nalloc = len;

Expand Down Expand Up @@ -533,7 +470,9 @@ void CRC_Array<T>::add(const T & k)

extend(Nelements + 1, false);

e[Nelements++] = k;
e.push_back(k);

Nelements++;

return;

Expand All @@ -555,7 +494,9 @@ int j;

for (j=0; j<(a.Nelements); ++j) {

e[Nelements++] = a.e[j];
e.push_back(a.e[j]);

Nelements++;

}

Expand Down Expand Up @@ -604,7 +545,7 @@ void CRC_Array<T>::sort_increasing()

if ( Nelements <= 1 ) return;

qsort(e, Nelements, sizeof(*e), is_bigger<T>);
std::sort(e.begin(), e.end());

return;

Expand Down
Loading

0 comments on commit 04bd3c0

Please sign in to comment.