From: Ulya Trofimovich Date: Thu, 14 May 2015 11:21:26 +0000 (+0100) Subject: Fixed mismatched new/delelte (found by valgrind). X-Git-Tag: 0.15~266 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8322a21500836c2949c58eeb11153213a4eed605;p=re2c Fixed mismatched new/delelte (found by valgrind). What is allocated with 're2c::allocate' (operator new), should be freed with 'operator delete', not with 'delete' or 'delete []'. --- diff --git a/re2c/src/codegen/dfa_prepare.cc b/re2c/src/codegen/dfa_prepare.cc index 42415990..6a630407 100644 --- a/re2c/src/codegen/dfa_prepare.cc +++ b/re2c/src/codegen/dfa_prepare.cc @@ -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 (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) diff --git a/re2c/src/codegen/go_construct.cc b/re2c/src/codegen/go_construct.cc index bec1098b..3db733a7 100644 --- a/re2c/src/codegen/go_construct.cc +++ b/re2c/src/codegen/go_construct.cc @@ -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; diff --git a/re2c/src/codegen/skeleton/skeleton.cc b/re2c/src/codegen/skeleton/skeleton.cc index 73df589e..128e08fa 100644 --- a/re2c/src/codegen/skeleton/skeleton.cc +++ b/re2c/src/codegen/skeleton/skeleton.cc @@ -247,7 +247,7 @@ Skeleton::Skeleton (const DFA & dfa) Skeleton::~Skeleton () { - delete [] nodes; + operator delete (nodes); } void Skeleton::generate_paths (std::vector & results) diff --git a/re2c/src/dfa/actions.cc b/re2c/src/dfa/actions.cc index 06b13884..dd512ae8 100644 --- a/re2c/src/dfa/actions.cc +++ b/re2c/src/dfa/actions.cc @@ -1020,8 +1020,8 @@ CharSet::CharSet() CharSet::~CharSet() { - delete[] rep; - delete[] ptn; + operator delete (rep); + operator delete (ptn); } smart_ptr genCode(RegExp *re, Output & output, uint32_t ind) diff --git a/re2c/src/dfa/dfa.cc b/re2c/src/dfa/dfa.cc index 1d4aa5f3..074cf0c2 100644 --- a/re2c/src/dfa/dfa.cc +++ b/re2c/src/dfa/dfa.cc @@ -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() diff --git a/re2c/src/dfa/state.cc b/re2c/src/dfa/state.cc index d92ac071..0d2e0f09 100644 --- a/re2c/src/dfa/state.cc +++ b/re2c/src/dfa/state.cc @@ -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)