Skip to content

Commit 4b516f5

Browse files
committed
Optimized drawMemoryWatchValueString to not use strncpy
1 parent 8592685 commit 4b516f5

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

ttyd-tools/rel/source/draw.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,25 +1432,20 @@ void drawMemoryWatchValueString(int32_t slot, int32_t posX,
14321432
uint32_t Size = sizeof(TextString);
14331433
clearMemory(TextString, Size);
14341434

1435-
// Get the size of the current string
1435+
// Get each character to draw one at a time
14361436
// Stop if an invalid address is reached
1437-
uint32_t Length = 0;
1438-
14391437
for (uint32_t i = 0; i < (Size - 1); i++)
14401438
{
14411439
if (checkIfPointerIsValid(&ValueString[i]) && (ValueString[i] != '\0'))
14421440
{
1443-
Length++;
1441+
TextString[i] = ValueString[i];
14441442
}
14451443
else
14461444
{
14471445
break;
14481446
}
14491447
}
14501448

1451-
// Get the text to draw
1452-
strncpy(TextString, ValueString, Length);
1453-
14541449
// Draw the text
14551450
drawText(TextString, posX, posY, alpha, color, scale);
14561451
}

0 commit comments

Comments
 (0)