Implemented B_TRUNCATE_MIDDLE, since truncate_strings() could corrupt memory

before in this mode. Some further cleanup, only B_TRUNCATE_BEGINNING is still
left.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13154 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-06-15 16:49:04 +00:00
parent 2e8bd79774
commit 2d4b179de5
2 changed files with 133 additions and 42 deletions
+3 -3
View File
@@ -807,14 +807,14 @@ BFont::GetTruncatedStrings(const char *stringArray[], int32 numStrings,
uint32 mode, float width, BString resultArray[]) const
{
if (stringArray && resultArray && numStrings > 0) {
// allocate storage, see BeBook for "+ 3"
// allocate storage, see BeBook for "+ 3" (make space for ellipsis)
char** truncatedStrings = new char*[numStrings];
for (int32 i = 0; i < numStrings; i++) {
truncatedStrings[i] = new char[strlen(stringArray[i]) + 3];
}
GetTruncatedStrings(stringArray, numStrings, mode, width, truncatedStrings);
// copy the strings into the BString array and free each one
for (int32 i = 0; i < numStrings; i++) {
resultArray[i].SetTo(truncatedStrings[i]);