This commit is contained in:
Shwartsman 2023-11-26 17:41:53 +02:00
commit 6d5e527e7d
10 changed files with 53 additions and 15 deletions

View File

@ -1871,6 +1871,15 @@ void bx_reset_options()
#endif
}
void bx_cleanup_options()
{
free(config_interface_list);
free(display_library_list);
free(vga_extension_names);
free(vga_extension_plugins);
free(pcislot_dev_list);
}
int bx_read_configuration(const char *rcfile)
{
// parse rcfile first, then parse arguments in order.

View File

@ -358,7 +358,7 @@ void bx_init_siminterface()
}
}
void bx_cleanup_siminterface()
int bx_cleanup_siminterface()
{
if (siminterface_log) {
delete siminterface_log;
@ -368,6 +368,11 @@ void bx_cleanup_siminterface()
delete root_param;
root_param = NULL;
}
io->exit_log2();
delete io;
int exit_code = SIM->get_exit_code();
delete SIM;
return exit_code;
}
bx_real_sim_c::bx_real_sim_c()

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2021 The Bochs Project
// Copyright (C) 2001-2023 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -770,7 +770,7 @@ public:
BOCHSAPI extern bx_simulator_interface_c *SIM;
extern void bx_init_siminterface();
extern void bx_cleanup_siminterface();
extern int bx_cleanup_siminterface();
#if defined(__WXMSW__) || defined(WIN32)
// Just to provide HINSTANCE, etc. in files that have not included bochs.h.

View File

@ -128,11 +128,6 @@ void bx_devices_c::init(BX_MEM_C *newmem)
io_write_handlers.next = &io_write_handlers;
io_write_handlers.prev = &io_write_handlers;
io_write_handlers.usage_count = 0; // not used with the default handler
if (read_port_to_handler)
delete [] read_port_to_handler;
if (write_port_to_handler)
delete [] write_port_to_handler;
read_port_to_handler = new struct io_handler_struct *[PORTS];
write_port_to_handler = new struct io_handler_struct *[PORTS];
@ -430,6 +425,9 @@ void bx_devices_c::exit()
delete [] curr->handler_name;
delete curr;
}
// delete default read handler name
delete [] io_read_handlers.handler_name;
io_read_handlers.handler_name = NULL;
struct io_handler_struct *io_write_handler = io_write_handlers.next;
while (io_write_handler != &io_write_handlers) {
io_write_handler->prev->next = io_write_handler->next;
@ -439,6 +437,15 @@ void bx_devices_c::exit()
delete [] curr->handler_name;
delete curr;
}
// delete default write handler name
delete [] io_write_handlers.handler_name;
io_write_handlers.handler_name = NULL;
// delete port-to-handler tables
if (read_port_to_handler)
delete [] read_port_to_handler;
if (write_port_to_handler)
delete [] write_port_to_handler;
// delete IRQ handler names
for (int i = 0; i < BX_MAX_IRQS; i++) {
delete [] irq_handler_name[i];
irq_handler_name[i] = NULL;

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2021 The Bochs Project
// Copyright (C) 2011-2023 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -45,6 +45,11 @@ bx_soundmod_ctl_c::bx_soundmod_ctl_c()
put("soundctl", "SNDCTL");
}
bx_soundmod_ctl_c::~bx_soundmod_ctl_c()
{
free(sound_driver_names);
}
void bx_soundmod_ctl_c::init()
{
Bit8u i, count = 0;

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2021 The Bochs Project
// Copyright (C) 2011-2023 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -29,7 +29,7 @@ class bx_soundlow_midiout_c;
class BOCHSAPI bx_soundmod_ctl_c : public logfunctions {
public:
bx_soundmod_ctl_c();
~bx_soundmod_ctl_c() {}
~bx_soundmod_ctl_c();
void init(void);
void exit(void);
const char **get_driver_names();

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2020 The Bochs Project
// Copyright (C) 2001-2023 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -171,6 +171,7 @@ void iofunctions::init_log(int fd)
init_log(tmpfd);
};
// called at simulation exit
void iofunctions::exit_log()
{
flush();
@ -182,6 +183,13 @@ void iofunctions::exit_log()
}
}
// called at application exit
void iofunctions::exit_log2()
{
delete log;
delete genlog;
}
// all other functions may use genlog safely.
#define LOG_THIS genlog->

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2021 The Bochs Project
// Copyright (C) 2001-2023 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -112,6 +112,7 @@ public:
void init_log(int fd);
void init_log(FILE *fs);
void exit_log();
void exit_log2();
void set_log_prefix(const char *prefix);
int get_n_logfns() const { return n_logfn; }
logfunc_t *get_logfn(int index) { return logfn_list[index]; }

View File

@ -68,6 +68,7 @@ int bx_init_main(int argc, char *argv[]);
void bx_init_hardware(void);
void bx_plugin_ctrl_reset(bool init_done);
void bx_init_options(void);
void bx_cleanup_options(void);
void bx_init_bx_dbg(void);
static const char *divider = "========================================================================";
@ -352,8 +353,9 @@ int bxmain(void)
#endif
plugin_cleanup();
BX_INSTR_EXIT_ENV();
bx_cleanup_siminterface();
return SIM->get_exit_code();
int exit_code = bx_cleanup_siminterface();
bx_cleanup_options();
return exit_code;
}
#if defined(__WXMSW__)

View File

@ -670,6 +670,7 @@ void plugin_cleanup(void)
#else
plugin_cleanup_np();
#endif
delete pluginlog;
}