Mercurial > hg > octave-lojdl
changeset 11501:331fcc41ca23
data member initialization fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 13 Jan 2011 03:04:51 -0500 |
parents | 7aeb4eb7403f |
children | 4638800cd660 |
files | liboctave/ChangeLog liboctave/CollocWt.h liboctave/MatrixType.cc liboctave/Quad.h liboctave/dir-ops.cc liboctave/dir-ops.h liboctave/kpse.cc liboctave/mach-info.cc liboctave/mach-info.h liboctave/oct-fftw.cc liboctave/oct-mutex.cc liboctave/oct-mutex.h liboctave/oct-shlib.cc liboctave/oct-shlib.h liboctave/oct-sort.h liboctave/oct-time.cc liboctave/oct-time.h liboctave/pathsearch.h liboctave/regex-match.h |
diffstat | 19 files changed, 125 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,37 @@ +2011-01-13 John W. Eaton <jwe@octave.org> + + * 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 <jwe@octave.org> * cmd-hist.h, cmd-hist.cc: Sprinkle with const.
--- a/liboctave/CollocWt.h +++ b/liboctave/CollocWt.h @@ -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,
--- a/liboctave/MatrixType.cc +++ b/liboctave/MatrixType.cc @@ -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) {
--- a/liboctave/Quad.h +++ b/liboctave/Quad.h @@ -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) { }
--- a/liboctave/dir-ops.cc +++ b/liboctave/dir-ops.cc @@ -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; -}
--- a/liboctave/dir-ops.h +++ b/liboctave/dir-ops.h @@ -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
--- a/liboctave/kpse.cc +++ b/liboctave/kpse.cc @@ -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; };
--- a/liboctave/mach-info.cc +++ b/liboctave/mach-info.cc @@ -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)
--- a/liboctave/mach-info.h +++ b/liboctave/mach-info.h @@ -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;
--- a/liboctave/oct-fftw.cc +++ b/liboctave/oct-fftw.cc @@ -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;
--- a/liboctave/oct-mutex.cc +++ b/liboctave/oct-mutex.cc @@ -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 ()) { }
--- a/liboctave/oct-mutex.h +++ b/liboctave/oct-mutex.h @@ -51,8 +51,8 @@ octave_mutex (void); octave_mutex (const octave_mutex& m) + : rep (m.rep) { - rep = m.rep; rep->count++; }
--- a/liboctave/oct-shlib.cc +++ b/liboctave/oct-shlib.cc @@ -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;
--- a/liboctave/oct-shlib.h +++ b/liboctave/oct-shlib.h @@ -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++; }
--- a/liboctave/oct-sort.h +++ b/liboctave/oct-sort.h @@ -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)
--- a/liboctave/oct-time.cc +++ b/liboctave/oct-time.cc @@ -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;
--- a/liboctave/oct-time.h +++ b/liboctave/oct-time.h @@ -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) {
--- a/liboctave/pathsearch.h +++ b/liboctave/pathsearch.h @@ -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 ();
--- a/liboctave/regex-match.h +++ b/liboctave/regex-match.h @@ -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