Local string.

This commit is contained in:
2025-08-04 10:41:05 -04:00
parent 8a3e2aae1c
commit 35b54bbc0c

View File

@ -143,7 +143,7 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s)
// Convert the a pattern like 'a1bc3d4' into a string of chars 'abcd' // Convert the a pattern like 'a1bc3d4' into a string of chars 'abcd'
// and a list of points [ 0, 1, 0, 3, 4 ]. // and a list of points [ 0, 1, 0, 3, 4 ].
int l = strlen (s); int l = strlen (s);
char *chars = new char[l + 1]; std::string chars;
SimpleVector<char> points (1); SimpleVector<char> points (1);
// TODO numbers consisting of multiple digits? // TODO numbers consisting of multiple digits?
@ -155,7 +155,8 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s)
points.setSize(numChars + 1, '0'); points.setSize(numChars + 1, '0');
points.set(numChars, s[i]); points.set(numChars, s[i]);
} else { } else {
chars[numChars++] = s[i]; numChars++;
chars+= s[i];
} }
} }
chars[numChars] = 0; chars[numChars] = 0;
@ -169,8 +170,7 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s)
//printf("insertPattern %s\n", chars); //printf("insertPattern %s\n", chars);
trieBuilder->insert (chars, points.getArray ()); trieBuilder->insert (chars.c_str(), points.getArray ());
delete[] chars;
} }
void Hyphenator::insertException (char *s) void Hyphenator::insertException (char *s)