This patch fixes bugs in various constructors. It also
explicit constructor and an explicit virtual destructor
This text looks prettier if you read it under Emacs
with M-x outline-mode.
*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
*All classes now have virtual destructors. This is
needed so that
destructors on polymorphic subclassed objects will work
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
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
but sneakily fail in C++. I fixed them.
For example, the no-arg constructor:
did not initialize the new folder object's folder name.
invoked the constructor Folder(string), which then in
turn instantiated a
new Folder with its title set to "New Folder", and then
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
initializations from the constructor code.
*Redundant code consolidated.
Some classes (such as Folder or Server) with more than
now have each constructor call a single central
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
and the like) that I've already used in my own Althea
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
this is a good thing to have. The idea is well
discussed in Kernighan
and Pike's ``The Practice of Programming'' and in Steve
``Writing Solid Code''