T2345: Replace instances of NULL with nullptr
The following changes have been applied to src and lib folders: regex replace: ([^"_])NULL ⇒ \1nullptr (8968 chgs in src, 1153 in lib) Manually find/change: (void \*) nullptr ⇒ nullptr (1 case) regex find: ".*?nullptr.*?" Manually ~14 cases back to "NULL" in src, ~2 in lib regex finds a few false positive where nullptr appears between two strings in a function call
This commit is contained in:
@ -57,7 +57,7 @@ template<typename T>
|
||||
Array2D<T>::Array2D() {
|
||||
nrows_ = 0;
|
||||
ncols_ = 0;
|
||||
data_ = NULL;
|
||||
data_ = nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -71,8 +71,8 @@ template<typename T>
|
||||
Array2D<T>::Array2D(const Array2D<T>& A) {
|
||||
nrows_ = A.nrows_;
|
||||
ncols_ = A.ncols_;
|
||||
if (A.data_==NULL)
|
||||
data_ = NULL;
|
||||
if (A.data_==nullptr)
|
||||
data_ = nullptr;
|
||||
else {
|
||||
data_ = new T[nrows_ * ncols_];
|
||||
for(int i=0;i<nrows_*ncols_;i++)
|
||||
@ -88,12 +88,12 @@ void Array2D<T>::reset(int nrows, int ncols) {
|
||||
else { // size changed; realloc memory
|
||||
nrows_ = nrows;
|
||||
ncols_ = ncols;
|
||||
if (data_ != NULL)
|
||||
if (data_ != nullptr)
|
||||
delete [] data_;
|
||||
if (ncols_ > 0 && nrows_ > 0)
|
||||
data_ = new T[nrows_ * ncols_];
|
||||
else {
|
||||
data_ = NULL;
|
||||
data_ = nullptr;
|
||||
nrows_ = 0;
|
||||
ncols_ = 0;
|
||||
}
|
||||
@ -120,11 +120,11 @@ AliasArray<T> Array2D<T>::column(int col) const {
|
||||
|
||||
template<typename T>
|
||||
Array2D<T>& Array2D<T>::operator= (const Array2D<T>& other) {
|
||||
if (data_ == NULL) { // initialize my internal storage to match LHS
|
||||
if (data_ == nullptr) { // initialize my internal storage to match LHS
|
||||
nrows_ = other.nrows_;
|
||||
ncols_ = other.ncols_;
|
||||
if (other.data_==NULL)
|
||||
data_ = NULL;
|
||||
if (other.data_==nullptr)
|
||||
data_ = nullptr;
|
||||
else
|
||||
data_ = new T[nrows_ * ncols_];
|
||||
}
|
||||
@ -170,14 +170,14 @@ void Array2D<T>::write_restart(FILE *f) const {
|
||||
|
||||
template<typename T>
|
||||
Array2D<T>::~Array2D() {
|
||||
if (data_ != NULL)
|
||||
if (data_ != nullptr)
|
||||
delete[] data_;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Array2D<T>::print(std::string name) const {
|
||||
std::cout << "------- Begin "<<name<<" -----------------\n";
|
||||
if (data_ != NULL) {
|
||||
if (data_ != nullptr) {
|
||||
for(int col=0;col<ncols_;col++) {
|
||||
for(int row=0;row<nrows_;row++) {
|
||||
std::cout << data_[col*nrows_ + row] << " ";
|
||||
|
||||
Reference in New Issue
Block a user