- destructors added to fix memory leaks

- indent mode fixes and removed unnecessary spaces
This commit is contained in:
Volker Ruppert 2007-03-10 12:53:54 +00:00
parent 8ce336cad3
commit e5dbe40511
2 changed files with 158 additions and 124 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: hdimage.cc,v 1.9 2006-11-18 11:51:07 vruppert Exp $
// $Id: hdimage.cc,v 1.10 2007-03-10 12:53:54 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -1267,6 +1267,11 @@ growing_image_t::growing_image_t()
redolog = new redolog_t();
}
growing_image_t::~growing_image_t()
{
delete redolog;
}
int growing_image_t::open(const char* pathname)
{
int filedes = redolog->open(pathname, REDOLOG_SUBTYPE_GROWING);
@ -1312,6 +1317,12 @@ undoable_image_t::undoable_image_t(const char* _redolog_name)
}
}
undoable_image_t::~undoable_image_t()
{
delete redolog;
delete ro_disk;
}
int undoable_image_t::open(const char* pathname)
{
char *logname=NULL;
@ -1400,6 +1411,12 @@ volatile_image_t::volatile_image_t(const char* _redolog_name)
}
}
volatile_image_t::~volatile_image_t()
{
delete redolog;
delete ro_disk;
}
int volatile_image_t::open(const char* pathname)
{
int filedes;
@ -1492,7 +1509,7 @@ z_ro_image_t::z_ro_image_t()
offset = (Bit64s)0;
}
int z_ro_image_t::open (const char* pathname)
int z_ro_image_t::open(const char* pathname)
{
fd = ::open(pathname, O_RDONLY
#ifdef O_BINARY
@ -1510,7 +1527,7 @@ int z_ro_image_t::open (const char* pathname)
return 0;
}
void z_ro_image_t::close ()
void z_ro_image_t::close()
{
if (fd > -1) {
gzclose(gzfile);
@ -1533,13 +1550,13 @@ Bit64s z_ro_image_t::lseek(Bit64s _offset, int whence)
return offset;
}
ssize_t z_ro_image_t::read (void* buf, size_t count)
ssize_t z_ro_image_t::read(void* buf, size_t count)
{
gzseek(gzfile, offset, SEEK_SET);
return gzread(gzfile, buf, count);
}
ssize_t z_ro_image_t::write (const void* buf, size_t count)
ssize_t z_ro_image_t::write(const void* buf, size_t count)
{
BX_PANIC(("z_ro_image: write not supported"));
return 0;
@ -1562,7 +1579,13 @@ z_undoable_image_t::z_undoable_image_t(Bit64u _size, const char* _redolog_name)
}
}
int z_undoable_image_t::open (const char* pathname)
z_undoable_image_t::~z_undoable_image_t()
{
delete redolog;
delete ro_disk;
}
int z_undoable_image_t::open(const char* pathname)
{
char *logname=NULL;
@ -1598,7 +1621,7 @@ int z_undoable_image_t::open (const char* pathname)
return 0;
}
void z_undoable_image_t::close ()
void z_undoable_image_t::close()
{
redolog->close();
ro_disk->close();
@ -1613,7 +1636,7 @@ Bit64s z_undoable_image_t::lseek(Bit64s offset, int whence)
return ro_disk->lseek(offset, whence);
}
ssize_t z_undoable_image_t::read (void* buf, size_t count)
ssize_t z_undoable_image_t::read(void* buf, size_t count)
{
// This should be fixed if count != 512
if (redolog->read((char*) buf, count) != count)
@ -1622,7 +1645,7 @@ ssize_t z_undoable_image_t::read (void* buf, size_t count)
return count;
}
ssize_t z_undoable_image_t::write (const void* buf, size_t count)
ssize_t z_undoable_image_t::write(const void* buf, size_t count)
{
return redolog->write((char*) buf, count);
}
@ -1645,7 +1668,13 @@ z_volatile_image_t::z_volatile_image_t(Bit64u _size, const char* _redolog_name)
}
}
int z_volatile_image_t::open (const char* pathname)
z_volatile_image_t::~z_volatile_image_t()
{
delete redolog;
delete ro_disk;
}
int z_volatile_image_t::open(const char* pathname)
{
int filedes;
const char *logname=NULL;
@ -1654,8 +1683,8 @@ int z_volatile_image_t::open (const char* pathname)
return -1;
// if redolog name was set
if ( redolog_name != NULL) {
if ( strcmp(redolog_name, "") !=0 ) {
if (redolog_name != NULL) {
if (strcmp(redolog_name, "") !=0 ) {
logname = redolog_name;
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: hdimage.h,v 1.8 2006-12-27 15:21:03 vruppert Exp $
// $Id: hdimage.h,v 1.9 2007-03-10 12:53:54 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2005 MandrakeSoft S.A.
@ -376,6 +376,7 @@ class growing_image_t : public device_image_t
public:
// Contructor
growing_image_t();
virtual ~growing_image_t();
// Open a image. Returns non-negative if successful.
int open(const char* pathname);
@ -405,6 +406,7 @@ class undoable_image_t : public device_image_t
public:
// Contructor
undoable_image_t(const char* redolog_name);
virtual ~undoable_image_t();
// Open a image. Returns non-negative if successful.
int open(const char* pathname);
@ -437,6 +439,7 @@ class volatile_image_t : public device_image_t
public:
// Contructor
volatile_image_t(const char* redolog_name);
virtual ~volatile_image_t();
// Open a image. Returns non-negative if successful.
int open(const char* pathname);
@ -507,6 +510,7 @@ class z_undoable_image_t : public device_image_t
public:
// Contructor
z_undoable_image_t(Bit64u size, const char* redolog_name);
virtual ~z_undoable_image_t();
// Open a image. Returns non-negative if successful.
int open(const char* pathname);
@ -539,6 +543,7 @@ class z_volatile_image_t : public device_image_t
public:
// Contructor
z_volatile_image_t(Bit64u size, const char* redolog_name);
virtual ~z_volatile_image_t();
// Open a image. Returns non-negative if successful.
int open(const char* pathname);