]> granicus.if.org Git - re2c/commitdiff
Fixed mismatched new/delelte (found by valgrind).
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 14 May 2015 11:21:26 +0000 (12:21 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 14 May 2015 11:21:26 +0000 (12:21 +0100)
What is allocated with 're2c::allocate<T>' (operator new), should
be freed with 'operator delete', not with 'delete' or 'delete []'.

re2c/src/codegen/dfa_prepare.cc
re2c/src/codegen/go_construct.cc
re2c/src/codegen/skeleton/skeleton.cc
re2c/src/dfa/actions.cc
re2c/src/dfa/dfa.cc
re2c/src/dfa/state.cc

index 42415990293456b87981ec07ad81ef711d63c5f0..6a63040751246f167d6682863e14ea1c809c3caa 100644 (file)
@@ -136,7 +136,7 @@ void DFA::findBaseState()
 
                                        if (nSpans < s->go.nSpans)
                                        {
-                                               delete [] s->go.span;
+                                               operator delete (s->go.span);
                                                s->go.nSpans = nSpans;
                                                s->go.span = allocate<Span> (nSpans);
                                                memcpy(s->go.span, span, nSpans*sizeof(Span));
@@ -148,7 +148,7 @@ void DFA::findBaseState()
                }
        }
 
-       delete [] span;
+       operator delete (span);
 }
 
 void DFA::prepare(uint32_t & max_fill)
index bec1098b79335e4a81aa421f8d70a174ee09be0f..3db733a7d3d2d7f23e9906d77fd9bcf3e882ab9a 100644 (file)
@@ -137,7 +137,7 @@ GoBitmap::GoBitmap (const Span * span, uint32_t nSpans, const Span * hspan, uint
        lgo = bSpans == 0
                ? NULL
                :  new SwitchIf (bspan, bSpans, next);
-       delete [] bspan;
+       operator delete (bspan);
 }
 
 const uint32_t CpgotoTable::TABLE_SIZE = 0x100;
index 73df589eefd7c002655923e607c79b7f9d681a74..128e08fa8753cc96e959876041ca22a7db3aaf8a 100644 (file)
@@ -247,7 +247,7 @@ Skeleton::Skeleton (const DFA & dfa)
 
 Skeleton::~Skeleton ()
 {
-       delete [] nodes;
+       operator delete (nodes);
 }
 
 void Skeleton::generate_paths (std::vector<Path> & results)
index 06b1388475cff9da1678bdbfa2223b95313d0378..dd512ae8a51d70b53bafdbf47a31b9536c6379f0 100644 (file)
@@ -1020,8 +1020,8 @@ CharSet::CharSet()
        
 CharSet::~CharSet()
 {
-       delete[] rep;
-       delete[] ptn;
+       operator delete (rep);
+       operator delete (ptn);
 }
 
 smart_ptr<DFA> genCode(RegExp *re, Output & output, uint32_t ind)
index 1d4aa5f3e18ee880b2f17768892e149cfc03cf96..074cf0c2b9ce93f711486a071e48c53f012ef061 100644 (file)
@@ -127,7 +127,7 @@ DFA::DFA(Ins *ins, uint32_t ni, uint32_t lb, uint32_t ub, const Char *rep)
 
        delete [] work;
        delete [] goTo;
-       delete [] span;
+       operator delete (span);
 }
 
 DFA::~DFA()
index d92ac0716d44bc6bd0e428f1323ed12e8b4b02e4..0d2e0f09af977d06798b4e9708db3241a53d49c4 100644 (file)
@@ -22,7 +22,7 @@ State::~State ()
 {
        delete action;
        delete [] kernel;
-       delete [] go.span;
+       operator delete (go.span);
 }
 
 std::ostream & operator << (std::ostream & o, const State & s)