Fix some but not all memory leaks in test/utf8 demo

Note: Fl_Input::value() copies the string to an internal buffer,
  fl_strdup() before value() is not necessary.
This commit is contained in:
Albrecht Schlosser 2023-05-08 16:26:07 +02:00
parent 712fc72fef
commit ac7b55d8bb
1 changed files with 7 additions and 2 deletions

View File

@ -622,10 +622,10 @@ int main(int argc, char** argv)
snprintf(bu, sizeof(bu), "0x%06X", y * 16);
Fl_Input *b = new Fl_Input(200,(y-off)*25,80,25);
b->textfont(FL_COURIER);
b->value(fl_strdup(bu));
b->value(bu);
b = new Fl_Input(280,(y-off)*25,380,25);
b->textfont(extra_font);
b->value(fl_strdup(buf));
b->value(buf);
}
scroll.end();
main_win->resizable(scroll);
@ -644,6 +644,11 @@ int main(int argc, char** argv)
utf8u[l] = '\0';
i3.value(utf8u);
// free strings that are no longer used
free(utf8u);
free(utf8l);
free(utf8);
const char *ltr_txt = "\\->e\xCC\x82=\xC3\xAA";
Fl_Input i4(5, 90, 190, 25);
i4.value(ltr_txt);