(de)allocation functions in FTerm

This commit is contained in:
Markus Gans 2017-12-21 00:45:04 +01:00
parent ff1fe44132
commit b886143701
3 changed files with 46 additions and 32 deletions

View File

@ -1,5 +1,6 @@
2017-12-21 Markus Gans <guru.mail@muenster.de> 2017-12-21 Markus Gans <guru.mail@muenster.de>
* Refactoring FMenuBar::drawItems * Refactoring FMenuBar::drawItems
* (de)allocation functions in FTerm
2017-12-19 Markus Gans <guru.mail@muenster.de> 2017-12-19 Markus Gans <guru.mail@muenster.de>
* Refactoring FMenu::drawItems * Refactoring FMenu::drawItems

View File

@ -522,6 +522,8 @@ class FTerm
static void enableMouse(); static void enableMouse();
static void disableMouse(); static void disableMouse();
static void captureXTermFontAndTitle(); static void captureXTermFontAndTitle();
void allocationValues();
void deallocationValues();
void init(); void init();
void finish(); void finish();
static uInt cp437_to_unicode (uChar); static uInt cp437_to_unicode (uChar);

View File

@ -4355,10 +4355,8 @@ void FTerm::captureXTermFontAndTitle()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init() inline void FTerm::allocationValues()
{ {
init_term_object = this;
try try
{ {
opti_move = new FOptiMove(); opti_move = new FOptiMove();
@ -4373,8 +4371,49 @@ void FTerm::init()
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::abort(); std::abort();
} }
}
//----------------------------------------------------------------------
inline void FTerm::deallocationValues()
{
if ( encoding_set )
delete encoding_set;
if ( vt100_alt_char )
delete vt100_alt_char;
if ( sec_da )
delete sec_da;
if ( answer_back )
delete answer_back;
if ( xterm_title )
delete xterm_title;
if ( xterm_font )
delete xterm_font;
if ( mouse )
delete mouse;
if ( term )
delete term;
if ( opti_attr )
delete opti_attr;
if ( opti_move )
delete opti_move;
}
//----------------------------------------------------------------------
void FTerm::init()
{
init_term_object = this;
// Initialize global values for all objects // Initialize global values for all objects
allocationValues();
init_global_values(); init_global_values();
// Get file descriptor for standard input and standard output // Get file descriptor for standard input and standard output
@ -4634,35 +4673,7 @@ void FTerm::finish()
} }
#endif #endif
if ( encoding_set ) deallocationValues();
delete encoding_set;
if ( vt100_alt_char )
delete vt100_alt_char;
if ( sec_da )
delete sec_da;
if ( answer_back )
delete answer_back;
if ( xterm_title )
delete xterm_title;
if ( xterm_font )
delete xterm_font;
if ( mouse )
delete mouse;
if ( term )
delete term;
if ( opti_attr )
delete opti_attr;
if ( opti_move )
delete opti_move;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------