From 7c9825172c1391a699a5275b1473e285429e22e8 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 4 May 2013 17:45:47 +1000 Subject: Replacing raw pointers and allocations with std::string. --- src/RESearch.cxx | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/RESearch.cxx') diff --git a/src/RESearch.cxx b/src/RESearch.cxx index bef24e57b..efa23eb84 100644 --- a/src/RESearch.cxx +++ b/src/RESearch.cxx @@ -202,6 +202,8 @@ #include +#include + #include "CharClassify.h" #include "RESearch.h" @@ -265,36 +267,29 @@ void RESearch::Init() { sta = NOP; /* status of lastpat */ bol = 0; for (int i = 0; i < MAXTAG; i++) - pat[i] = 0; + pat[i].clear(); for (int j = 0; j < BITBLK; j++) bittab[j] = 0; } void RESearch::Clear() { for (int i = 0; i < MAXTAG; i++) { - delete []pat[i]; - pat[i] = 0; + pat[i].clear(); bopat[i] = NOTFOUND; eopat[i] = NOTFOUND; } } -bool RESearch::GrabMatches(CharacterIndexer &ci) { - bool success = true; +void RESearch::GrabMatches(CharacterIndexer &ci) { for (unsigned int i = 0; i < MAXTAG; i++) { if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) { unsigned int len = eopat[i] - bopat[i]; - pat[i] = new char[len + 1]; - if (pat[i]) { - for (unsigned int j = 0; j < len; j++) - pat[i][j] = ci.CharAt(bopat[i] + j); - pat[i][len] = '\0'; - } else { - success = false; - } + pat[i] = std::string(len+1, '\0'); + for (unsigned int j = 0; j < len; j++) + pat[i][j] = ci.CharAt(bopat[i] + j); + pat[i][len] = '\0'; } } - return success; } void RESearch::ChSet(unsigned char c) { -- cgit v1.2.3