diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-04-02 16:52:28 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-04-02 16:52:28 +0000 |
commit | 4b51acaca526d1f42054b35a1d26b7e5a8300db2 (patch) | |
tree | f8e083ac6def998896961252998b79160d76f638 /src | |
parent | fead8c64ea8bd003fdc583e22ca42d7cfadd6b22 (diff) |
add assert() checks that gridfn data pointers are non-null before
using them, and that they're null before setting them in setup_gridfn_storage()
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@419 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src')
-rw-r--r-- | src/patch/grid.cc | 3 | ||||
-rw-r--r-- | src/patch/grid.hh | 53 |
2 files changed, 46 insertions, 10 deletions
diff --git a/src/patch/grid.cc b/src/patch/grid.cc index 664ad1d..2904847 100644 --- a/src/patch/grid.cc +++ b/src/patch/grid.cc @@ -64,6 +64,7 @@ void grid_arrays::setup_gridfn_storage (const gridfn_pars& gridfn_pars_in, const gridfn_pars& ghosted_gridfn_pars_in, { +assert(gridfn_data_ == NULL); gridfn_data_ = new jtutil::array3d<fp>(gridfn_pars_in.min_gfn_in, gridfn_pars_in.max_gfn_in, grid_array_pars_in.min_irho, @@ -74,6 +75,8 @@ gridfn_data_ = new jtutil::array3d<fp>(gridfn_pars_in.min_gfn_in, gridfn_pars_in.stride_gfn, gridfn_pars_in.stride_irho, gridfn_pars_in.stride_isigma); + +assert(ghosted_gridfn_data == NULL); ghosted_gridfn_data = new jtutil::array3d<fp> (gridfn_pars_in.ghosted_min_gfn_in, diff --git a/src/patch/grid.hh b/src/patch/grid.hh index 0df5eb6..19413ff 100644 --- a/src/patch/grid.hh +++ b/src/patch/grid.hh @@ -320,32 +320,65 @@ public: // ... rvalue (may be slightly faster since it's a const function // and it returns by value rather than reference fp gridfn(int gfn, int irho, int isigma) const - { return gridfn_data_(gfn, irho, isigma); } + { + assert(gridfn_data_ != NULL); + return (*gridfn_data_)(gfn, irho, isigma); + } // ... lvalue (must return a reference) fp& gridfn(int gfn, int irho, int isigma) - { return gridfn_data_(gfn, irho, isigma); } + { + assert(gridfn_data_ != NULL); + return (*gridfn_data_)(gfn, irho, isigma); + } // access to ghosted-grid gridfn data // ... rvalue (may be slightly faster since it's a const function // and it returns by value rather than reference fp ghosted_gridfn(int gfn, int irho, int isigma) const - { return ghosted_gridfn_data_(gfn, irho, isigma); } + { + assert(gridfn_data_ != NULL); + return (*ghosted_gridfn_data_)(gfn, irho, isigma); + } // ... lvalue (must return a reference) fp& ghosted_gridfn(int gfn, int irho, int isigma) - { return ghosted_gridfn_data_(gfn, irho, isigma); } + { + assert(gridfn_data_ != NULL); + return (*ghosted_gridfn_data_)(gfn, irho, isigma); + } // subscripting info - int gfn_stride() const { return gridfn_data_.subscript_stride_i(); } - int irho_stride() const { return gridfn_data_.subscript_stride_j(); } - int isigma_stride() const { return gridfn_data_.subscript_stride_k(); } + int gfn_stride() const + { + assert(gridfn_data_ != NULL); + return gridfn_data_->subscript_stride_i(); + } + int irho_stride() const + { + assert(gridfn_data_ != NULL); + return gridfn_data_->subscript_stride_j(); + } + int isigma_stride() const + { + assert(gridfn_data_ != NULL); + return gridfn_data_->subscript_stride_k(); + } int iang_stride(bool want_rho) const { return want_rho ? irho_stride() : isigma_stride(); } int ghosted_gfn_stride() const - { return ghosted_gridfn_data_.subscript_stride_i(); } + { + assert(ghosted_gridfn_data_ != NULL); + return ghosted_gridfn_data_->subscript_stride_i(); + } int ghosted_irho_stride() const - { return ghosted_gridfn_data_.subscript_stride_j(); } + { + assert(ghosted_gridfn_data_ != NULL); + return ghosted_gridfn_data_->subscript_stride_j(); + } int ghosted_isigma_stride() const - { return ghosted_gridfn_data_.subscript_stride_k(); } + { + assert(ghosted_gridfn_data_ != NULL); + return ghosted_gridfn_data_->subscript_stride_k(); + } int ghosted_iang_stride(bool want_rho) const { return want_rho ? ghosted_irho_stride() |