diff --git a/MMVII/include/MMVII_Ptxd.h b/MMVII/include/MMVII_Ptxd.h index f928868108..bfb7e5a4d7 100755 --- a/MMVII/include/MMVII_Ptxd.h +++ b/MMVII/include/MMVII_Ptxd.h @@ -61,7 +61,7 @@ template class cPtxd } /// Some function requires default constructor (serialization ?) - cPtxd() {} + cPtxd() : mCoords{} {} /* I would prefer not inline but : cannot make work explicit instance of a a specific method, and explicit of the whole class create problem diff --git a/MMVII/include/SymbDer/SymbDer_Common.h b/MMVII/include/SymbDer/SymbDer_Common.h index d39a1f3188..2eccf79673 100755 --- a/MMVII/include/SymbDer/SymbDer_Common.h +++ b/MMVII/include/SymbDer/SymbDer_Common.h @@ -433,6 +433,7 @@ template class cName2Calc { if (SVP) return nullptr; UserSError("Cannot extract allocator. Check that this application was recompiled after code generation",aName); + return nullptr; } return anIter->second; } diff --git a/include/ext_stl/fifo.h b/include/ext_stl/fifo.h index a542df9e52..2eb5315233 100755 --- a/include/ext_stl/fifo.h +++ b/include/ext_stl/fifo.h @@ -197,6 +197,9 @@ template class ElFifo void incr_capa() { + if (_capa == 0) + _capa = 1; + Type * NewTab = new Type [2*_capa]; for (INT kk=0; kk<_nb ; kk++) NewTab[kk] = _tab[(kk+_begin)%_capa]; diff --git a/src/TpMMPD/DeformAnalyse.cpp b/src/TpMMPD/DeformAnalyse.cpp index ef47c79b2a..d7a3b41dab 100755 --- a/src/TpMMPD/DeformAnalyse.cpp +++ b/src/TpMMPD/DeformAnalyse.cpp @@ -76,7 +76,7 @@ int DeformAnalyse_main (int argc, char ** argv) // 3. get the vector PerResidu ifstream aPR((aDir + aOut1).c_str()); - char *aPerR; + char *aPerR{nullptr}; if(aPR) { std::string aLine; diff --git a/src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp b/src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp index 20263756eb..ce8e6ef019 100755 --- a/src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp +++ b/src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp @@ -116,7 +116,7 @@ void cAppliTaskCorrel::ReadXMLMesurePts(string aGCPMesureXML, vector & aMes = iT1->OneMesureAF1I(); string aNameIm = iT1->NameIm(); cout<Name()) diff --git a/src/photogram/DataBase.cpp b/src/photogram/DataBase.cpp index 8d8e0c28fb..808e534c81 100755 --- a/src/photogram/DataBase.cpp +++ b/src/photogram/DataBase.cpp @@ -239,7 +239,8 @@ std::string cInterfChantierNameManipulateur::DBNameTransfo std::string aName = aNameInit; std::string aSep = aDBNT.Separateur().Val(); int aMode = MMUserEnv().VersionNameCam().ValWithDef(1); - const cMetaDataPhoto & aMDP = cMetaDataPhoto::CreateExiv2(mDir+aName); + auto path = mDir+aName; + const cMetaDataPhoto & aMDP = cMetaDataPhoto::CreateExiv2(path); double aFoc = aMDP.FocMm(true); std::string aCompl = ""; diff --git a/src/uti_image/CPP_Vignette.cpp b/src/uti_image/CPP_Vignette.cpp index eb4cce5ea4..656a9507cb 100755 --- a/src/uti_image/CPP_Vignette.cpp +++ b/src/uti_image/CPP_Vignette.cpp @@ -479,7 +479,8 @@ vector Make_Grp(std::string aDir, std::string InCal, std::vector flow = 0; } -template - void Graph::reallocate_nodes(int num) -{ - int node_num_max = (int)(node_max - nodes); - node* nodes_old = nodes; - - node_num_max += node_num_max / 2; - if (node_num_max < node_num + num) node_num_max = node_num + num; - nodes = (node*) realloc(nodes_old, node_num_max*sizeof(node)); - if (!nodes) { if (error_function) (*error_function)("Not enough memory!"); exit(1); } - - node_last = nodes + node_num; - node_max = nodes + node_num_max; - - if (nodes != nodes_old) - { - node* i; - arc* a; - for (i=nodes; inext) i->next = (node*) ((char*)i->next + (((char*) nodes) - ((char*) nodes_old))); - } - for (a=arcs; ahead = (node*) ((char*)a->head + (((char*) nodes) - ((char*) nodes_old))); - } - } +template +void Graph::reallocate_nodes(int num) { + int node_num_max = (int)(node_max - nodes); + size_t nodes_old = (size_t)nodes; + + node_num_max += node_num_max / 2; + if (node_num_max < node_num + num) node_num_max = node_num + num; + + nodes = (node*)realloc(nodes, node_num_max * sizeof(node)); + + if (!nodes) { + if (error_function) (*error_function)("Not enough memory!"); + exit(1); + } + + node_last = nodes + node_num; + node_max = nodes + node_num_max; + + if ((size_t)nodes != nodes_old) { + node* i; + arc* a; + for (i = nodes; i < node_last; i++) { + if (i->next) + i->next = + (node*)((size_t)i->next + + (((size_t)nodes) - ((size_t)nodes_old))); + } + for (a = arcs; a < arc_last; a++) { + a->head = (node*)((size_t)a->head + + (((size_t)nodes) - ((size_t)nodes_old))); + } + } } -template - void Graph::reallocate_arcs() -{ - int arc_num_max = (int)(arc_max - arcs); - int arc_num = (int)(arc_last - arcs); - arc* arcs_old = arcs; - - arc_num_max += arc_num_max / 2; if (arc_num_max & 1) arc_num_max ++; - arcs = (arc*) realloc(arcs_old, arc_num_max*sizeof(arc)); - if (!arcs) { if (error_function) (*error_function)("Not enough memory!"); exit(1); } - - arc_last = arcs + arc_num; - arc_max = arcs + arc_num_max; - - if (arcs != arcs_old) - { - node* i; - arc* a; - for (i=nodes; ifirst) i->first = (arc*) ((char*)i->first + (((char*) arcs) - ((char*) arcs_old))); - if (i->parent && i->parent != ORPHAN && i->parent != TERMINAL) i->parent = (arc*) ((char*)i->parent + (((char*) arcs) - ((char*) arcs_old))); - } - for (a=arcs; anext) a->next = (arc*) ((char*)a->next + (((char*) arcs) - ((char*) arcs_old))); - a->sister = (arc*) ((char*)a->sister + (((char*) arcs) - ((char*) arcs_old))); - } - } +template +void Graph::reallocate_arcs() { + int arc_num_max = (int)(arc_max - arcs); + int arc_num = (int)(arc_last - arcs); + size_t arcs_old = (size_t)arcs; + + arc_num_max += arc_num_max / 2; + if (arc_num_max & 1) arc_num_max++; + arcs = (arc*)realloc(arcs, arc_num_max * sizeof(arc)); + if (!arcs) { + if (error_function) (*error_function)("Not enough memory!"); + exit(1); + } + + arc_last = arcs + arc_num; + arc_max = arcs + arc_num_max; + + if ((size_t)arcs != arcs_old) { + node* i; + arc* a; + for (i = nodes; i < node_last; i++) { + if (i->first) + i->first = (arc*)((size_t)i->first + + (((size_t)arcs) - ((size_t)arcs_old))); + if (i->parent && i->parent != ORPHAN && + i->parent != TERMINAL) + i->parent = (arc*)((size_t)i->parent + + (((size_t)arcs) - ((size_t)arcs_old))); + } + for (a = arcs; a < arc_last; a++) { + if (a->next) + a->next = (arc*)((size_t)a->next + + (((size_t)arcs) - ((size_t)arcs_old))); + a->sister = (arc*)((size_t)a->sister + + (((size_t)arcs) - ((size_t)arcs_old))); + } + } } #include "instances.inc" diff --git a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp index b5600dde89..aa54045911 100755 --- a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp +++ b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp @@ -190,7 +190,7 @@ template { code_assert(node_num_max_new > node_shift/((int)sizeof(Node))); Node* nodes_old[2] = { nodes[0], nodes[1] }; - + auto size = ((char*)nodes_old[1] - (char*)nodes_old[0]); int node_num_max = node_num_max_new; nodes[0] = (Node*) realloc(nodes_old[0], 2*node_num_max*sizeof(Node)); if (!nodes[0]) { if (error_function) (*error_function)("Not enough memory!"); exit(1); } @@ -202,7 +202,7 @@ template node_max[1] = nodes[1] + node_num_max; if (stage) { - memmove(nodes[1], (char*)nodes[0] + ((char*)nodes_old[1] - (char*)nodes_old[0]), node_num*sizeof(Node)); + memmove(nodes[1], (char*)nodes[0] + size, node_num*sizeof(Node)); } Arc* a; diff --git a/src/util/regex.cpp b/src/util/regex.cpp index e8b0b2f255..b36df743e3 100755 --- a/src/util/regex.cpp +++ b/src/util/regex.cpp @@ -106,7 +106,7 @@ cElRegex::cElRegex(const std::string & aNameExprIn,int aNbMatchMax,int aCFlag,bo if (! IsOk()) return; - regmatch_t aMatch; + regmatch_t aMatch{}; mVMatch.reserve(aNbMatchMax); for (int aK=0; aK