- remove logfunction from list when device is deleted

- fixed typos in harddrv code
This commit is contained in:
Volker Ruppert 2006-09-17 18:09:33 +00:00
parent ec9c361e9c
commit fdefdc5b9f
3 changed files with 27 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: bochs.h,v 1.197 2006-09-12 13:05:07 vruppert Exp $
// $Id: bochs.h,v 1.198 2006-09-17 18:09:33 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -320,10 +320,11 @@ public:
void init_log(FILE *fs);
void exit_log();
void set_log_prefix(const char *prefix);
int get_n_logfns () { return n_logfn; }
logfunc_t *get_logfn (int index) { return logfn_list[index]; }
void add_logfn (logfunc_t *fn);
void set_log_action (int loglevel, int action);
int get_n_logfns() { return n_logfn; }
logfunc_t *get_logfn(int index) { return logfn_list[index]; }
void add_logfn(logfunc_t *fn);
void remove_logfn(logfunc_t *fn);
void set_log_action(int loglevel, int action);
const char *getlevel(int i) {
static const char *loglevel[N_LOGLEV] = {
"DEBUG",

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: harddrv.cc,v 1.185 2006-09-16 14:47:40 vruppert Exp $
// $Id: harddrv.cc,v 1.186 2006-09-17 18:09:33 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -110,7 +110,7 @@ bx_hard_drive_c::bx_hard_drive_c()
for (Bit8u channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
for (Bit8u device=0; device<2; device ++) {
channels[channel].drives[device].hard_drive = NULL;
#ifdef LOWLOVEL_CDROM
#ifdef LOWLEVEL_CDROM
channels[channel].drives[device].cdrom.cd = NULL;
#endif
}
@ -127,7 +127,7 @@ bx_hard_drive_c::~bx_hard_drive_c()
delete channels[channel].drives[device].hard_drive;
channels[channel].drives[device].hard_drive = NULL;
}
#ifdef LOWLOVEL_CDROM
#ifdef LOWLEVEL_CDROM
if (channels[channel].drives[device].cdrom.cd != NULL) {
delete channels[channel].drives[device].cdrom.cd;
channels[channel].drives[device].cdrom.cd = NULL;
@ -146,7 +146,7 @@ void bx_hard_drive_c::init(void)
char ata_name[20];
bx_list_c *base;
BX_DEBUG(("Init $Id: harddrv.cc,v 1.185 2006-09-16 14:47:40 vruppert Exp $"));
BX_DEBUG(("Init $Id: harddrv.cc,v 1.186 2006-09-17 18:09:33 vruppert Exp $"));
for (channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
sprintf(ata_name, "ata.%d.resources", channel);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: logio.cc,v 1.56 2006-09-09 11:28:52 vruppert Exp $
// $Id: logio.cc,v 1.57 2006-09-17 18:09:33 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -71,6 +71,21 @@ void iofunctions::add_logfn(logfunc_t *fn)
logfn_list[n_logfn++] = fn;
}
void iofunctions::remove_logfn(logfunc_t *fn)
{
assert(n_logfn > 0);
int i = 0;
while ((fn != logfn_list[i]) && (i < n_logfn)) {
i++;
};
if (i < n_logfn) {
for (int j=i; j<n_logfn-1; j++) {
logfn_list[j] = logfn_list[j+1];
}
n_logfn--;
}
}
void iofunctions::set_log_action(int loglevel, int action)
{
for(int i=0; i<n_logfn; i++)
@ -287,6 +302,7 @@ logfunctions::logfunctions(iofunc_t *iofunc)
logfunctions::~logfunctions()
{
this->logio->remove_logfn(this);
if (prefix) free(prefix);
}