From: Steven Augart <swa@au...> - 2002-02-15 09:51:52
I'll upload this patch sometime in the next day or two.
Any comments or questions before I do so?
This patch fixes bugs in various constructors. It also defines an
explicit constructor and an explicit virtual destructor for every
*All of the constructors and destructors are now defined in the
appropriate <class>.cpp file, instead of being inline in the <class>.h
file. This reduces the size of the executable; otherwise they get
redundantly instantiated in every source file they're used in.
*All classes now have virtual destructors. This is needed so that
destructors on polymorphic subclassed objects will work properly
even when they're being referred to by a pointer to objects of an
*Bugs fixed in various constructors:
**class Althea: Needed a constructor to zero-initialize some members.
This never showed up because the only instances of objects of the
Althea class are both global variables, and with globals, their memory
starts off automatically zeroed at program load time.
The result of *that* is that if someone ever *were* to instantiate an object
of class Althea on the stack or via the memory manager, the bug would
only appear then.
*Some classes had constructors that would have worked in Java,
but sneakily fail in C++. I fixed them.
For example, the no-arg constructor:
did not initialize the new folder object's folder name. Instead, it
invoked the constructor Folder(string), which then in turn instantiated a
new Folder with its title set to "New Folder", and then immediately
destroyed that new Folder!
The classes Server and Folder had this bug.
*Old Folder constructor did not initialize server_ptr.
Lurking bug. Fixed.
*strings are initialized to "" by default
so no need to do it again in a constructor. I've excised such
initializations from the constructor code.
*Redundant code consolidated.
Some classes (such as Folder or Server) with more than one constructor
now have each constructor call a single central initialize() function.
This removed code duplication.
*All classes now have constructors and destructors.
Some of these are empty in the patches I'm submitting here. They are
important in my own work, though. In *my* working tree, they
initialize some #ifndef NDEBUG internal consistency checks (assertions
and the like) that I've already used in my own Althea sources to
catch bad-pointer bugs quickly.
I do not plan to send patches for those consistency checks unless one
of the core developers actually cares about it and understands why
this is a good thing to have. The idea is well discussed in Kernighan
and Pike's ``The Practice of Programming'' and in Steve McConnell's
``Writing Solid Code''