# HG changeset patch # User John W. Eaton # Date 1294905891 18000 # Node ID 331fcc41ca234ad4a05ab958ec7029afcb2ccfcb # Parent 7aeb4eb7403ff633ea39c9e46f4265e9a2d0880f data member initialization fixes diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/ChangeLog --- a/liboctave/ChangeLog Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/ChangeLog Thu Jan 13 03:04:51 2011 -0500 @@ -1,3 +1,37 @@ +2011-01-13 John W. Eaton + + * kpse.cc (struct str_llist_elt, struct cache_entry): + Explicitly define constructor and destructor. + + * Quad.h (Quad::Quad, IndefQuad::IndefQuad, + FloatIndefQuad::FloatIndefQuad): Initialize all data members in + initialization lists. + * CollocWt.h (CollocWt::CollocWt): Likewise. + * oct-time.h (octave_strptime::octave_strptime): Likewise. + * oct-time.cc (octave_time::octave_time): Likewise. + * pathsearch.h (dir_path::dir_path): Likewise. + * regex-match.h (regex_match::regex_match): Likewise. + * oct-sort.h (octave_sort::MergeState::MergeState): Likewise. + * oct-shlib.h, oct-shlib.cc (octave_shlib::shlib_rep::shlib_rep, + octave_shlib::octave_shlib): Likewise. + * oct-mutex.h, oct-mutex.cc (octave_mutex::octave_mutex): Likewise. + * MatrixType.cc (MatrixType::MatrixType): Likewise. + * oct-fftw.cc (octave_fftw_planner::octave_fftw_planner, + octave_float_fftw_planner::octave_float_fftw_planner): Likewise. + + * mach-info.h, mach-info.cc (oct_mach_info::oct_mach_info): + Initialize all data members in initialization lists. + (ten_little_endians): Rename from oct_mach_info::ten_little_endians. + Now static instead of private member function + (get_float_format): Rename from oct_mach_info::init_float_format. + Now static instead of private member function. + + * dir-ops.h, dir-ops.cc (dir_entry::copy): Delete. + (dir_entry::dir_entry): Initialize all data members in + initialization lists. + (dir_entry::operator =): Copy elements directly here instead of + calling copy. + 2011-01-13 John W. Eaton * cmd-hist.h, cmd-hist.cc: Sprinkle with const. diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/CollocWt.h --- a/liboctave/CollocWt.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/CollocWt.h Thu Jan 13 03:04:51 2011 -0500 @@ -51,7 +51,7 @@ CollocWt (octave_idx_type nc, double a, double b, octave_idx_type il, octave_idx_type ir) : n (nc), inc_left (il), inc_right (ir), lb (0.0), rb (1.0), - Alpha (a), Beta (b), initialized (false) { } + Alpha (a), Beta (b), r (), q (), A (), B (), initialized (false) { } CollocWt (octave_idx_type nc, double a, double b, octave_idx_type il, octave_idx_type ir, diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/MatrixType.cc --- a/liboctave/MatrixType.cc Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/MatrixType.cc Thu Jan 13 03:04:51 2011 -0500 @@ -47,7 +47,7 @@ MatrixType::MatrixType (const MatrixType &a) : typ (a.typ), sp_bandden (a.sp_bandden), bandden (a.bandden), upper_band (a.upper_band), lower_band (a.lower_band), - dense (a.dense), full (a.full), nperm (a.nperm) + dense (a.dense), full (a.full), nperm (a.nperm), perm (0) { if (nperm != 0) { diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/Quad.h --- a/liboctave/Quad.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/Quad.h Thu Jan 13 03:04:51 2011 -0500 @@ -53,10 +53,10 @@ public: Quad (integrand_fcn fcn) - : Quad_options (), f (fcn) { } + : Quad_options (), f (fcn), ff () { } Quad (float_integrand_fcn fcn) - : Quad_options (), ff (fcn) { } + : Quad_options (), f (), ff (fcn) { } virtual ~Quad (void) { } @@ -164,10 +164,10 @@ enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite }; IndefQuad (integrand_fcn fcn) - : Quad (fcn), bound (0.0), type (bound_to_inf) { } + : Quad (fcn), bound (0.0), type (bound_to_inf), integration_error (0) { } IndefQuad (integrand_fcn fcn, double b, IntegralType t) - : Quad (fcn), bound (b), type (t) { } + : Quad (fcn), bound (b), type (t), integration_error (0) { } ~IndefQuad (void) { } @@ -226,10 +226,10 @@ enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite }; FloatIndefQuad (float_integrand_fcn fcn) - : Quad (fcn), bound (0.0), type (bound_to_inf) { } + : Quad (fcn), bound (0.0), type (bound_to_inf), integration_error (0) { } FloatIndefQuad (float_integrand_fcn fcn, double b, IntegralType t) - : Quad (fcn), bound (b), type (t) { } + : Quad (fcn), bound (b), type (t), integration_error (0) { } ~FloatIndefQuad (void) { } diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/dir-ops.cc --- a/liboctave/dir-ops.cc Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/dir-ops.cc Thu Jan 13 03:04:51 2011 -0500 @@ -99,12 +99,3 @@ dir = 0; } - -void -dir_entry::copy (const dir_entry& de) -{ - name = de.name; - dir = de.dir; - fail = de.fail; - errmsg = de.errmsg; -} diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/dir-ops.h --- a/liboctave/dir-ops.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/dir-ops.h Thu Jan 13 03:04:51 2011 -0500 @@ -33,18 +33,25 @@ { public: - dir_entry (const std::string& n = std::string ()) : name (n), dir (0) + dir_entry (const std::string& n = std::string ()) + : name (n), dir (0), fail (false), errmsg () { if (! name.empty ()) open (); } - dir_entry (const dir_entry& d) { copy (d); } + dir_entry (const dir_entry& d) + : name (d.name), dir (d.dir), fail (d.fail), errmsg (d.errmsg) { } dir_entry& operator = (const dir_entry& d) { if (this != &d) - copy (d); + { + name = d.name; + dir = d.dir; + fail = d.fail; + errmsg = d.errmsg; + } return *this; } @@ -78,8 +85,6 @@ // If a failure occurs, this contains the system error text. std::string errmsg; - - void copy (const dir_entry&); }; #endif diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/kpse.cc --- a/liboctave/kpse.cc Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/kpse.cc Thu Jan 13 03:04:51 2011 -0500 @@ -312,6 +312,10 @@ struct str_llist_elt { + str_llist_elt (void) : str (), moved (0), next (0) { } + + ~str_llist_elt (void) { } + std::string str; int moved; struct str_llist_elt *next; @@ -1693,6 +1697,13 @@ struct kpse_format_info_type { + kpse_format_info_type (void) + : type (), path (), raw_path (), path_source (), override_path (), + client_path (), cnf_path (), default_path (), suffix () + { } + + ~kpse_format_info_type (void) { } + std::string type; /* Human-readable description. */ std::string path; /* The search path to use. */ std::string raw_path; /* Pre-$~ (but post-default) expansion. */ @@ -2081,6 +2092,10 @@ struct cache_entry { + cache_entry (void) : key (), value (0) { } + + ~cache_entry (void) { } + std::string key; str_llist_type *value; }; diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/mach-info.cc --- a/liboctave/mach-info.cc Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/mach-info.cc Thu Jan 13 03:04:51 2011 -0500 @@ -70,9 +70,11 @@ return 1; } -void -oct_mach_info::init_float_format (void) const +static oct_mach_info::float_format +get_float_format (void) { + oct_mach_info::float_format retval = oct_mach_info::flt_fmt_unknown; + #if defined (CRAY) // FIXME -- this should be determined automatically. @@ -125,17 +127,19 @@ { if (equiv_compare (fp[i].fp_par, mach_fp_par, 4)) { - native_float_fmt = fp[i].fp_fmt; + retval = fp[i].fp_fmt; break; } } while (fp[++i].fp_fmt != oct_mach_info::flt_fmt_unknown); #endif + + return retval; } -void -oct_mach_info::ten_little_endians (void) const +static bool +ten_little_endians (void) { // Are we little or big endian? From Harbison & Steele. @@ -147,14 +151,12 @@ u.l = 1; - big_chief = (u.c[sizeof (long) - 1] == 1); + return (u.c[sizeof (long) - 1] == 1); } oct_mach_info::oct_mach_info (void) -{ - init_float_format (); - ten_little_endians (); -} + : native_float_fmt (get_float_format ()), + big_chief (ten_little_endians ()) { } bool oct_mach_info::instance_ok (void) diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/mach-info.h --- a/liboctave/mach-info.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/mach-info.h Thu Jan 13 03:04:51 2011 -0500 @@ -62,10 +62,6 @@ static oct_mach_info *instance; - void init_float_format (void) const; - - void ten_little_endians (void) const; - // The floating point format for the current machine. mutable float_format native_float_fmt; diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/oct-fftw.cc --- a/liboctave/oct-fftw.cc Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/oct-fftw.cc Thu Jan 13 03:04:51 2011 -0500 @@ -56,6 +56,8 @@ // ffts. octave_fftw_planner::octave_fftw_planner (void) + : meth (), rplan (), rd (0), rs (0), rr (0), rh (0), rn (0), + rsimd_align (false) { meth = ESTIMATE; @@ -369,6 +371,8 @@ octave_float_fftw_planner *octave_float_fftw_planner::instance = 0; octave_float_fftw_planner::octave_float_fftw_planner (void) + : meth (), rplan (), rd (0), rs (0), rr (0), rh (0), rn (0), + rsimd_align (false) { meth = ESTIMATE; diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/oct-mutex.cc --- a/liboctave/oct-mutex.cc Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/oct-mutex.cc Thu Jan 13 03:04:51 2011 -0500 @@ -83,7 +83,7 @@ { public: octave_pthread_mutex (void) - : octave_base_mutex () + : octave_base_mutex (), pm () { pthread_mutexattr_t attr; @@ -114,13 +114,16 @@ #endif -octave_mutex::octave_mutex (void) +static octave_base_mutex * +init_rep (void) { #if defined (__WIN32__) && ! defined (__CYGWIN__) - rep = new octave_w32_mutex (); + return new octave_w32_mutex (); #elif defined (HAVE_PTHREAD_H) - rep = new octave_pthread_mutex (); + return new octave_pthread_mutex (); #else - rep = new octave_base_mutex (); + return new octave_base_mutex (); #endif } + +octave_mutex::octave_mutex (void) : rep (init_rep ()) { } diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/oct-mutex.h --- a/liboctave/oct-mutex.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/oct-mutex.h Thu Jan 13 03:04:51 2011 -0500 @@ -51,8 +51,8 @@ octave_mutex (void); octave_mutex (const octave_mutex& m) + : rep (m.rep) { - rep = m.rep; rep->count++; } diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/oct-shlib.cc --- a/liboctave/oct-shlib.cc Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/oct-shlib.cc Thu Jan 13 03:04:51 2011 -0500 @@ -61,7 +61,7 @@ #include "str-vec.h" octave_shlib::shlib_rep::shlib_rep (const std::string& f) - : count (1), file (f), tm_loaded () + : count (1), file (f), tm_loaded (), fcn_names () { instances[f] = this; diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/oct-shlib.h --- a/liboctave/oct-shlib.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/oct-shlib.h Thu Jan 13 03:04:51 2011 -0500 @@ -43,7 +43,7 @@ public: shlib_rep (void) - : count (1), file (), tm_loaded (time_t ()) { } + : count (1), file (), tm_loaded (time_t ()), fcn_names () { } protected: @@ -121,8 +121,8 @@ } octave_shlib (const octave_shlib& sl) + : rep (sl.rep) { - rep = sl.rep; rep->count++; } diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/oct-sort.h --- a/liboctave/oct-sort.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/oct-sort.h Thu Jan 13 03:04:51 2011 -0500 @@ -182,8 +182,8 @@ struct MergeState { - MergeState (void) - : a (0), ia (0), alloced (0) + MergeState (void) + : min_gallop (), a (0), ia (0), alloced (0), n (0) { reset (); } ~MergeState (void) diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/oct-time.cc --- a/liboctave/oct-time.cc Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/oct-time.cc Thu Jan 13 03:04:51 2011 -0500 @@ -39,6 +39,7 @@ #include "oct-time.h" octave_time::octave_time (const octave_base_tm& tm) + : ot_unix_time (), ot_usec () { struct tm t; diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/oct-time.h --- a/liboctave/oct-time.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/oct-time.h Thu Jan 13 03:04:51 2011 -0500 @@ -333,10 +333,13 @@ public: octave_strptime (const std::string& str, const std::string& fmt) - : octave_base_tm () { init (str, fmt); } + : octave_base_tm (), nchars (0) + { + init (str, fmt); + } octave_strptime (const octave_strptime& s) - : octave_base_tm (s) { nchars = s.nchars; } + : octave_base_tm (s), nchars (s.nchars) { } octave_strptime& operator = (const octave_strptime& s) { diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/pathsearch.h --- a/liboctave/pathsearch.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/pathsearch.h Thu Jan 13 03:04:51 2011 -0500 @@ -36,7 +36,7 @@ dir_path (const std::string& s = std::string (), const std::string& d = std::string ()) - : p_orig (s), p_default (d), initialized (false) + : p_orig (s), p_default (d), initialized (false), p (), pv () { if (! p_orig.empty ()) init (); diff -r 7aeb4eb7403f -r 331fcc41ca23 liboctave/regex-match.h --- a/liboctave/regex-match.h Thu Jan 13 02:48:07 2011 -0500 +++ b/liboctave/regex-match.h Thu Jan 13 03:04:51 2011 -0500 @@ -43,13 +43,31 @@ public: regex_match (const std::string& p, bool insen = false) - : pat (p), case_insen (insen) { init (); } + : pat (p), case_insen (insen) +#if HAVE_REGEX + , compiled (0) +#endif + { + init (); + } regex_match (const string_vector& p = string_vector (), bool insen = false) - : pat (p), case_insen (insen) { init (); } + : pat (p), case_insen (insen) +#if HAVE_REGEX + , compiled (0) +#endif + { + init (); + } regex_match (const regex_match& gm) - : pat (gm.pat), case_insen (gm.case_insen) { init (); } + : pat (gm.pat), case_insen (gm.case_insen) +#if HAVE_REGEX + , compiled (0) +#endif + { + init (); + } regex_match& operator = (const regex_match& gm); @@ -76,7 +94,6 @@ #if HAVE_REGEX regex_t *compiled; #endif - }; #endif