diff options
| author | nyamatongwe <devnull@localhost> | 2013-05-04 17:45:47 +1000 |
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2013-05-04 17:45:47 +1000 |
| commit | 7c9825172c1391a699a5275b1473e285429e22e8 (patch) | |
| tree | ebf9b0f0a7a6544cecb8e112f88950fdb7a6cb8e /src/RESearch.cxx | |
| parent | b06956e4248bd4222576d35d8827c65b09fcd9d7 (diff) | |
| download | scintilla-mirror-7c9825172c1391a699a5275b1473e285429e22e8.tar.gz | |
Replacing raw pointers and allocations with std::string.
Diffstat (limited to 'src/RESearch.cxx')
| -rw-r--r-- | src/RESearch.cxx | 23 |
1 files changed, 9 insertions, 14 deletions
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 <stdlib.h> +#include <string> + #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) { |
