diff options
Diffstat (limited to 'src/util/didyoumean.cpp')
-rw-r--r-- | src/util/didyoumean.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/util/didyoumean.cpp b/src/util/didyoumean.cpp index 228fe721e..dd8941033 100644 --- a/src/util/didyoumean.cpp +++ b/src/util/didyoumean.cpp @@ -77,7 +77,12 @@ int DidYouMean::editDistance(const std::string& a, const std::string& b) int len1 = a.size(); int len2 = b.size(); - int C[3][len2+1]; // cost + int* C[3]; + int ii; + for (ii = 0; ii < 3; ++ii) { + C[ii] = new int[len2+1]; + } + // int C[3][len2+1]; // cost for(int j = 0; j <= len2; ++j) { C[0][j] = j * addCost; @@ -123,7 +128,11 @@ int DidYouMean::editDistance(const std::string& a, const std::string& b) } } - return C[len1%3][len2]; + int result = C[len1%3][len2]; + for (ii = 0; ii < 3; ++ii) { + delete [] C[ii]; + } + return result; } string DidYouMean::getMatchAsString(string input, int prefixNewLines, int suffixNewLines) { |