From f304ed29d6f2b92b872ffc2b218bc8398b879ef0 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 16 Oct 2013 22:21:27 +0200 Subject: cppcheck initialisation (bzr r12697) --- src/libcola/cola.cpp | 10 +++++----- src/libcola/gradient_projection.h | 23 +++++++++++++++++++++-- src/libcola/straightener.h | 4 ++-- src/xml/repr-io.cpp | 11 +++++++---- 4 files changed, 35 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp index 51560a79c..168ef5533 100644 --- a/src/libcola/cola.cpp +++ b/src/libcola/cola.cpp @@ -23,7 +23,8 @@ ConstrainedMajorizationLayout double* eweights, double idealLength, TestConvergence& done) - : constrainedLayout(false), + : avoidOverlaps(false), + constrainedLayout(false), n(rs.size()), lapSize(n), lap2(new double*[lapSize]), Q(lap2), Dij(new double*[lapSize]), @@ -116,18 +117,17 @@ void ConstrainedMajorizationLayout::majlayout( void ConstrainedMajorizationLayout::majlayout( double** Dij, GradientProjection* gp, double* coords, double* b) { - double L_ij,dist_ij,degree; /* compute the vector b */ /* multiply on-the-fly with distance-based laplacian */ for (unsigned i = 0; i < n; i++) { - degree = 0; if(i 1e-30 && Dij[i][j] > 1e-30) { /* skip zero distances */ /* calculate L_ij := w_{ij}*d_{ij}/dist_{ij} */ - L_ij = 1.0 / (dist_ij * Dij[i][j]); + double L_ij = 1.0 / (dist_ij * Dij[i][j]); degree -= L_ij; b[i] += L_ij * coords[j]; } diff --git a/src/libcola/gradient_projection.h b/src/libcola/gradient_projection.h index 8cf45586c..980fa6064 100644 --- a/src/libcola/gradient_projection.h +++ b/src/libcola/gradient_projection.h @@ -25,7 +25,12 @@ typedef std::vector SimpleConstraints; class AlignmentConstraint { friend class GradientProjection; public: - AlignmentConstraint(double pos) : position(pos), variable(NULL) {} + AlignmentConstraint(double pos) : + offsets(), + guide(NULL), + position(pos), + variable(NULL) + {} void updatePosition() { position = variable->position(); } @@ -74,7 +79,21 @@ typedef std::vector > CList; */ class DummyVarPair { public: - DummyVarPair(double desiredDist) : dist(desiredDist), lap2(1.0/(desiredDist*desiredDist)) { } + DummyVarPair(double desiredDist) : + leftof(), + rightof(), + place_l(0), + place_r(0), + dist(desiredDist), + b(0), + left(NULL), + right(NULL), + lap2(1.0/(desiredDist*desiredDist)), + g(0), + old_place_l(0), + old_place_r(0) + {} + CList leftof; // variables to which left dummy var must be to the left of CList rightof; // variables to which right dummy var must be to the right of double place_l; diff --git a/src/libcola/straightener.h b/src/libcola/straightener.h index b1ce665f4..927780140 100644 --- a/src/libcola/straightener.h +++ b/src/libcola/straightener.h @@ -38,7 +38,7 @@ namespace straightener { std::vector dummyNodes; std::vector path; Edge(unsigned id, unsigned start, unsigned end, Route* route) - : id(id), startNode(start), endNode(end), route(route) + : id(id), openInd(0), startNode(start), endNode(end), route(route) { route->boundingBox(xmin,ymin,xmax,ymax); } @@ -98,7 +98,7 @@ namespace straightener { double weight; bool open; Node(unsigned id, vpsc::Rectangle* r) : - id(id),x(r->getCentreX()),y(r->getCentreY()), width(r->width()), height(r->height()), + id(id),x(r->getCentreX()),y(r->getCentreY()), scanpos(0), width(r->width()), height(r->height()), xmin(x-width/2),xmax(x+width/2), ymin(y-height/2),ymax(y+height/2), edge(NULL),dummy(false),weight(-0.1),open(false) { } diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index f7e75a83b..54eff00bc 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -78,11 +78,14 @@ public: XmlSource() : filename(0), encoding(0), - fp(0), + fp(NULL), firstFewLen(0), + LoadEntities(false), + cachedData(), + cachedPos(0), dummy("x"), - instr(0), - gzin(0) + instr(NULL), + gzin(NULL) { for (int k=0;k<4;k++) { @@ -191,7 +194,7 @@ int XmlSource::setFile(char const *filename, bool load_entities=false) buffer[len] = 0; this->cachedData += buffer; } - free(buffer); + delete[] buffer; // Check for SYSTEM or PUBLIC entities and remove them from the cache GMatchInfo *info; -- cgit v1.2.3