Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modernize-use-nullptr #37

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/ADT.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@
{
ndim = 6;
nelem = 0;
adtIntegers = NULL;
adtReals = NULL;
adtExtents = NULL;
coord = NULL;
adtIntegers = nullptr;
adtReals = nullptr;
adtExtents = nullptr;
coord = nullptr;
};
~ADT()
{
if (adtIntegers) free(adtIntegers);

Check warning on line 55 in src/ADT.h

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

implicit conversion 'int *' -> bool [readability-implicit-bool-conversion]

Check warning on line 55 in src/ADT.h

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

statement should be inside braces [readability-braces-around-statements]
if (adtReals) free(adtReals);
if (adtExtents) free(adtExtents);
adtIntegers = NULL;
adtReals = NULL;
adtExtents = NULL;
adtIntegers = nullptr;
adtReals = nullptr;
adtExtents = nullptr;
};
void clearData(void)
{
if (adtIntegers) free(adtIntegers);
if (adtReals) free(adtReals);
if (adtExtents) free(adtExtents);
adtIntegers = NULL;
adtReals = NULL;
adtExtents = NULL;
adtIntegers = nullptr;
adtReals = nullptr;
adtExtents = nullptr;
};
void buildADT(int d, int nelements, double* elementBbox);
void searchADT(MeshBlock* mb, int* cellindx, double* xsearch);
Expand Down
46 changes: 23 additions & 23 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void CartBlock::getInterpolatedData(
int interpCount = 0;
double weight;
listptr = interpList;
while (listptr != NULL) {
while (listptr != nullptr) {
interpCount++;
listptr = listptr->next;
}
Expand Down Expand Up @@ -88,7 +88,7 @@ void CartBlock::getInterpolatedData(
icount = 3 * nintold;
dcount = nrealold;
qq = (double*)malloc(sizeof(double) * (nvar_cell + nvar_node));
while (listptr != NULL) {
while (listptr != nullptr) {
(*intData)[icount++] = listptr->receptorInfo[0];
(*intData)[icount++] = -1 - listptr->receptorInfo[2];
(*intData)[icount++] = listptr->receptorInfo[1];
Expand Down Expand Up @@ -160,7 +160,7 @@ void CartBlock::preprocess(CartGrid* cg)
void CartBlock::initializeLists(void)
{
donorList = (DONORLIST**)malloc(sizeof(DONORLIST*) * (ncell + nnode));
for (int i = 0; i < (ncell + nnode); i++) donorList[i] = NULL;
for (int i = 0; i < (ncell + nnode); i++) donorList[i] = nullptr;
}

void CartBlock::clearLists(void)
Expand All @@ -169,12 +169,12 @@ void CartBlock::clearLists(void)
if (donorList) {
for (i = 0; i < ncell + nnode; i++) {
deallocateLinkList(donorList[i]);
donorList[i] = NULL;
donorList[i] = nullptr;
}
TIOGA_FREE(donorList);
}
deallocateLinkList4(interpList);
interpList = NULL;
interpList = nullptr;
}

void CartBlock::insertInInterpList(
Expand All @@ -184,16 +184,16 @@ void CartBlock::insertInInterpList(
int ix[3];
double* rst;
rst = (double*)malloc(sizeof(double) * 3);
if (interpList == NULL) {
if (interpList == nullptr) {
interpList = (INTERPLIST2*)malloc(sizeof(INTERPLIST2));
listptr = interpList;
} else {
listptr->next = (INTERPLIST2*)malloc(sizeof(INTERPLIST2));
listptr = listptr->next;
}
listptr->next = NULL;
listptr->inode = NULL;
listptr->weights = NULL;
listptr->next = nullptr;
listptr->inode = nullptr;
listptr->weights = nullptr;
listptr->receptorInfo[0] = procid;
listptr->receptorInfo[1] = remoteid;
listptr->receptorInfo[2] = remoteblockid;
Expand Down Expand Up @@ -363,7 +363,7 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
xtmp[2] = xlo[2] + (k + 0.5) * dx[2];
}

if (donorList[idof] == NULL) {
if (donorList[idof] == nullptr) {
for (int h = 0; h < nmesh; h++)
if (holemap[h].existWall) {
if (checkHoleMap(
Expand All @@ -382,7 +382,7 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
} else {
temp = donorList[idof];
for (int h = 0; h < nmesh; h++) iflag[h] = 0;
while (temp != NULL) {
while (temp != nullptr) {
int meshtagdonor = temp->donorData[1] - BASE;
iflag[meshtagdonor] = 1;
temp = temp->next;
Expand Down Expand Up @@ -422,15 +422,15 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
dims[0], dims[1], nf, i, j, k);

if (iblank[ibindex] == 0) {
if (donorList[idof] != NULL) {
if (donorList[idof] != nullptr) {
temp = donorList[idof];
while (temp != NULL) {
while (temp != nullptr) {
temp->cancel = 1;
temp = temp->next;
}
}
} else {
if ((temp = donorList[idof]) != NULL) {
if ((temp = donorList[idof]) != nullptr) {
// simplify logic here: the first one on the list is the
// best donor anyway, accept it if its not a mandatory
// receptor on the donor side
Expand All @@ -439,7 +439,7 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
temp = temp->next;
}
// cancel other donors if some exist
while (temp != NULL) {
while (temp != nullptr) {
temp->cancel = 1;
temp = temp->next;
}
Expand Down Expand Up @@ -518,7 +518,7 @@ void CartBlock::processIblank(
xtmp[2] = xlo[2] + (k + 0.5) * dx[2];
}

if (donorList[idof] == NULL) {
if (donorList[idof] == nullptr) {
for (int h = 0; h < nmesh; h++)
if (holemap[h].existWall) {
int SB_val =
Expand All @@ -537,7 +537,7 @@ void CartBlock::processIblank(
} else {
temp = donorList[idof];
for (int h = 0; h < nmesh; h++) iflag[h] = 0;
while (temp != NULL) {
while (temp != nullptr) {
int meshtagdonor = temp->donorData[1] - BASE;
iflag[meshtagdonor] = 1;
temp = temp->next;
Expand Down Expand Up @@ -578,15 +578,15 @@ void CartBlock::processIblank(
dims[0], dims[1], nf, i, j, k);

if (iblank[ibindex] == 0) {
if (donorList[idof] != NULL) {
if (donorList[idof] != nullptr) {
temp = donorList[idof];
while (temp != NULL) {
while (temp != nullptr) {
temp->cancel = 1;
temp = temp->next;
}
}
} else {
if ((temp = donorList[idof]) != NULL) {
if ((temp = donorList[idof]) != nullptr) {
// simplify logic here: the first one on the list is the
// best donor anyway, accept it if its not a mandatory
// receptor on the donor side
Expand All @@ -595,7 +595,7 @@ void CartBlock::processIblank(
temp = temp->next;
}
// cancel other donors if some exist
while (temp != NULL) {
while (temp != nullptr) {
temp->cancel = 1;
temp = temp->next;
}
Expand Down Expand Up @@ -649,9 +649,9 @@ void CartBlock::getCancellationData(int* cancelledData, int* ncancel)
for (j = 0; j < dims[1] + isNodal; j++)
for (i = 0; i < dims[0] + isNodal; i++) {
idof++;
if (donorList[idof] != NULL) {
if (donorList[idof] != nullptr) {
temp = donorList[idof];
while (temp != NULL) {
while (temp != nullptr) {
if (temp->cancel == 1) {
(*ncancel)++;
cancelledData[m++] = temp->donorData[0];
Expand Down
12 changes: 6 additions & 6 deletions src/CartBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ class CartBlock
{
global_id = 0;
dims[0] = dims[1] = dims[2] = 0;
ibl_cell = NULL;
ibl_node = NULL;
qcell = NULL;
qnode = NULL;
ibl_cell = nullptr;
ibl_node = nullptr;
qcell = nullptr;
qnode = nullptr;
interpListSize = 0;
donorList = NULL;
interpList = NULL;
donorList = nullptr;
interpList = nullptr;
donor_frac = nullptr;
nvar_cell = 0;
nvar_node = 0;
Expand Down
14 changes: 7 additions & 7 deletions src/MeshBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void MeshBlock::setData(
for (i = 0; i < ntypes; i++) ncells += nc[i];

#ifdef TIOGA_HAS_NODEGID
if (nodeGID == NULL)
if (nodeGID == nullptr)
throw std::runtime_error("#tioga: global IDs for nodes not provided");
#endif
}
Expand Down Expand Up @@ -198,7 +198,7 @@ void MeshBlock::tagBoundary(void)
// userSpecifiedCellRes=NULL;

//
if (userSpecifiedNodeRes == NULL && userSpecifiedCellRes == NULL) {
if (userSpecifiedNodeRes == nullptr && userSpecifiedCellRes == nullptr) {
for (i = 0; i < nnodes; i++) nodeRes[i] = 0.0;

if (!dominanceFlag) {
Expand Down Expand Up @@ -510,7 +510,7 @@ void MeshBlock::tagBoundaryFaces(void)

// if duplicate found, set duplicate array pointer
const char* duplicateCheck =
(flagduplicate) ? iflagduplicates.data() : NULL;
(flagduplicate) ? iflagduplicates.data() : nullptr;

/* ======================================================== */
/* 2. COMPUTE LOCAL BOUNDING BOX (after adjusting iflagwbc) */
Expand Down Expand Up @@ -554,9 +554,9 @@ void MeshBlock::tagBoundaryFaces(void)
const int nfacevert = numfaceverts[ctype][f];
const int* faceNodes = faceInfo[ctype][f];

if (flagwbc &&
checkFaceBoundaryNodes(
inode, iflagwbc.data(), nfacevert, faceNodes, NULL))
if (flagwbc && checkFaceBoundaryNodes(
inode, iflagwbc.data(), nfacevert,
faceNodes, nullptr))
nwbcface++;
if (flagobc && checkFaceBoundaryNodes(
inode, iflagobc.data(), nfacevert,
Expand Down Expand Up @@ -601,7 +601,7 @@ void MeshBlock::tagBoundaryFaces(void)
// check wall boundary condition face
if (flagwbc && checkFaceBoundaryNodes(
inode, iflagwbc.data(), nfacevert,
faceNodes, NULL)) {
faceNodes, nullptr)) {
for (d = 0; d < 3; d++)
wbcfacenode[4 * nwbcface + d] =
inode[faceNodes[d] - BASE];
Expand Down
Loading
Loading