return nullptr instead of out-of-range data
This commit is contained in:
@ -113,7 +113,9 @@ class Modify : protected Pointers {
|
||||
int find_fix(const std::string &);
|
||||
// new API
|
||||
Fix *get_fix_by_id(const std::string &) const;
|
||||
Fix *get_fix_by_index(int idx) const { return fix[idx]; }
|
||||
Fix *get_fix_by_index(int idx) const {
|
||||
return ((idx >= 0) && (idx < nfix)) ? fix[idx] : nullptr;
|
||||
}
|
||||
const std::vector<Fix *> get_fix_by_style(const std::string &) const;
|
||||
const std::vector<Fix *> &get_fix_list();
|
||||
|
||||
@ -127,7 +129,9 @@ class Modify : protected Pointers {
|
||||
int find_compute(const std::string &);
|
||||
// new API
|
||||
Compute *get_compute_by_id(const std::string &) const;
|
||||
Compute *get_compute_by_index(int idx) const { return compute[idx]; }
|
||||
Compute *get_compute_by_index(int idx) const {
|
||||
return ((idx >= 0) && (idx < nfix)) ? compute[idx] : nullptr;
|
||||
}
|
||||
const std::vector<Compute *> get_compute_by_style(const std::string &) const;
|
||||
const std::vector<Compute *> &get_compute_list();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user