buffer allocation was wrong which caused excess allocations

it also may have written past the end of the buffer and lost
characters (including formatting characters, resulting in display glitches).
This commit is contained in:
Kelvin Sherlock 2021-07-07 18:43:53 -04:00
parent 8085d2c934
commit 1155573111
1 changed files with 3 additions and 3 deletions

6
nda.c
View File

@ -106,7 +106,7 @@ void AppendText(word length, char *cp) {
size = TextHandleUsed + length;
if (size > TextHandleSize) {
size += 4095;
size &= ~4096;
size &= ~4095;
if (h) {
HUnlock(h);
@ -153,7 +153,7 @@ void SetText(void) {
longword oldStart, oldEnd;
TESetSelection((Pointer)-1, (Pointer)-1, TECtrlHandle);
TESetText(teDataIsTextBox2|teTextIsPtr, (Ref)*TextHandle, TextHandleUsed, NULL, NULL, TECtrlHandle);
TESetText(teDataIsTextBox2|teTextIsPtr, (Ref)*TextHandle, TextHandleUsed, 0, NULL, TECtrlHandle);
TextHandleUsed = 0;
@ -540,7 +540,7 @@ void DoDefine(void) {
handle = (Handle)GetCtlHandleFromID(MyWindow, rCtrlTE);
TESetText(teDataIsTextBlock, (Ref)"", 0, NULL, NULL, handle);
TESetText(teDataIsTextBlock|teTextIsPtr, (Ref)"", 0, 0, NULL, handle);
GetLETextByID(MyWindow, rCtrlLE, (StringPtr)word_to_define);