From 35b54bbc0c1a83bc084a3de96e2fa56c0c2af62ab1676c431a93c52b2328259c Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Mon, 4 Aug 2025 10:41:05 -0400 Subject: [PATCH] Local string. --- dw/hyphenator.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dw/hyphenator.cc b/dw/hyphenator.cc index e64b673..d436c97 100644 --- a/dw/hyphenator.cc +++ b/dw/hyphenator.cc @@ -143,7 +143,7 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s) // Convert the a pattern like 'a1bc3d4' into a string of chars 'abcd' // and a list of points [ 0, 1, 0, 3, 4 ]. int l = strlen (s); - char *chars = new char[l + 1]; + std::string chars; SimpleVector points (1); // TODO numbers consisting of multiple digits? @@ -155,7 +155,8 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s) points.setSize(numChars + 1, '0'); points.set(numChars, s[i]); } else { - chars[numChars++] = s[i]; + numChars++; + chars+= s[i]; } } chars[numChars] = 0; @@ -169,8 +170,7 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s) //printf("insertPattern %s\n", chars); - trieBuilder->insert (chars, points.getArray ()); - delete[] chars; + trieBuilder->insert (chars.c_str(), points.getArray ()); } void Hyphenator::insertException (char *s)