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:
@ -24,10 +24,10 @@ namespace CSLIB_NS {
|
||||
#define ZMQ_REQ 0
|
||||
#define ZMQ_REP 0
|
||||
|
||||
static void *zmq_ctx_new() {return NULL;}
|
||||
static void *zmq_connect(void *, char *) {return NULL;}
|
||||
static void *zmq_ctx_new() {return nullptr;}
|
||||
static void *zmq_connect(void *, char *) {return nullptr;}
|
||||
static int zmq_bind(void *, char *) {return 0;}
|
||||
static void *zmq_socket(void *,int) {return NULL;}
|
||||
static void *zmq_socket(void *,int) {return nullptr;}
|
||||
static void zmq_close(void *) {}
|
||||
static void zmq_ctx_destroy(void *) {}
|
||||
static void zmq_send(void *, void *, int, int) {}
|
||||
|
||||
@ -57,7 +57,7 @@ CSlib::CSlib(int csflag, const char *mode, const void *ptr, const void *pcomm)
|
||||
else if (csflag == 1) server = 1;
|
||||
else error_all("constructor(): Invalid client/server arg");
|
||||
|
||||
if (pcomm == NULL) {
|
||||
if (pcomm == nullptr) {
|
||||
me = 0;
|
||||
nprocs = 1;
|
||||
|
||||
@ -82,19 +82,19 @@ CSlib::CSlib(int csflag, const char *mode, const void *ptr, const void *pcomm)
|
||||
}
|
||||
|
||||
maxfield = 0;
|
||||
fieldID = fieldtype = fieldlen = fieldoffset = NULL;
|
||||
fieldID = fieldtype = fieldlen = fieldoffset = nullptr;
|
||||
maxheader = 0;
|
||||
header = NULL;
|
||||
header = nullptr;
|
||||
maxbuf = 0;
|
||||
buf = NULL;
|
||||
buf = nullptr;
|
||||
|
||||
recvcounts = displs = NULL;
|
||||
recvcounts = displs = nullptr;
|
||||
maxglobal = 0;
|
||||
allids = NULL;
|
||||
allids = nullptr;
|
||||
maxfieldbytes = 0;
|
||||
fielddata = NULL;
|
||||
fielddata = nullptr;
|
||||
|
||||
pad = "\0\0\0\0\0\0\0"; // just length 7 since will have trailing NULL
|
||||
pad = "\0\0\0\0\0\0\0"; // just length 7 since will have trailing nullptr
|
||||
|
||||
nsend = nrecv = 0;
|
||||
}
|
||||
@ -218,7 +218,7 @@ void CSlib::pack_parallel(int id, int ftype,
|
||||
// nlocal datums, each of nper length, from all procs
|
||||
// final data in buf = datums for all natoms, ordered by ids
|
||||
|
||||
if (recvcounts == NULL) {
|
||||
if (recvcounts == nullptr) {
|
||||
recvcounts = (int *) smalloc(nprocs*sizeof(int));
|
||||
displs = (int *) smalloc(nprocs*sizeof(int));
|
||||
}
|
||||
@ -706,9 +706,9 @@ void CSlib::deallocate_fields()
|
||||
|
||||
void *CSlib::smalloc(int nbytes)
|
||||
{
|
||||
if (nbytes == 0) return NULL;
|
||||
if (nbytes == 0) return nullptr;
|
||||
void *ptr = malloc(nbytes);
|
||||
if (ptr == NULL) {
|
||||
if (ptr == nullptr) {
|
||||
char str[128];
|
||||
sprintf(str,"malloc(): Failed to allocate %d bytes",nbytes);
|
||||
error_one(str);
|
||||
@ -722,11 +722,11 @@ void *CSlib::srealloc(void *ptr, int nbytes)
|
||||
{
|
||||
if (nbytes == 0) {
|
||||
sfree(ptr);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ptr = realloc(ptr,nbytes);
|
||||
if (ptr == NULL) {
|
||||
if (ptr == nullptr) {
|
||||
char str[128];
|
||||
sprintf(str,"realloc(): Failed to reallocate %d bytes",nbytes);
|
||||
error_one(str);
|
||||
@ -738,7 +738,7 @@ void *CSlib::srealloc(void *ptr, int nbytes)
|
||||
|
||||
void CSlib::sfree(void *ptr)
|
||||
{
|
||||
if (ptr == NULL) return;
|
||||
if (ptr == nullptr) return;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ void cslib_open_fortran(int csflag, const char *mode, const char *str,
|
||||
const void *pcomm, void **csptr)
|
||||
{
|
||||
MPI_Comm ccomm;
|
||||
void *pccomm = NULL;
|
||||
void *pccomm = nullptr;
|
||||
|
||||
if (pcomm) {
|
||||
MPI_Fint *fcomm = (MPI_Fint *) pcomm;
|
||||
|
||||
@ -80,9 +80,9 @@ void Msg::allocate(int nheader, int &maxheader, int *&header,
|
||||
|
||||
void *Msg::smalloc(int nbytes)
|
||||
{
|
||||
if (nbytes == 0) return NULL;
|
||||
if (nbytes == 0) return nullptr;
|
||||
void *ptr = (void *) malloc(nbytes);
|
||||
if (ptr == NULL) {
|
||||
if (ptr == nullptr) {
|
||||
char str[128];
|
||||
sprintf(str,"Failed to allocate %d bytes",nbytes);
|
||||
}
|
||||
@ -93,7 +93,7 @@ void *Msg::smalloc(int nbytes)
|
||||
|
||||
void Msg::sfree(void *ptr)
|
||||
{
|
||||
if (ptr == NULL) return;
|
||||
if (ptr == nullptr) return;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ void MsgMPITwo::init(char *filename)
|
||||
{
|
||||
if (client) {
|
||||
if (me == 0) {
|
||||
FILE *fp = NULL;
|
||||
FILE *fp = nullptr;
|
||||
while (!fp) {
|
||||
fp = fopen(filename,"r");
|
||||
if (!fp) sleep(1);
|
||||
|
||||
@ -99,12 +99,12 @@ void MsgZMQ::send(int nheader, int *header, int nbuf, char *buf)
|
||||
|
||||
if (me == 0) {
|
||||
zmq_send(socket,lengths,2*sizeof(int),0);
|
||||
zmq_recv(socket,NULL,0,0);
|
||||
zmq_recv(socket,nullptr,0,0);
|
||||
}
|
||||
|
||||
if (me == 0) {
|
||||
zmq_send(socket,header,nheader*sizeof(int),0);
|
||||
zmq_recv(socket,NULL,0,0);
|
||||
zmq_recv(socket,nullptr,0,0);
|
||||
}
|
||||
|
||||
if (me == 0) zmq_send(socket,buf,nbuf,0);
|
||||
@ -125,7 +125,7 @@ void MsgZMQ::recv(int &maxheader, int *&header, int &maxbuf, char *&buf)
|
||||
{
|
||||
if (me == 0) {
|
||||
zmq_recv(socket,lengths,2*sizeof(int),0);
|
||||
zmq_send(socket,NULL,0,0);
|
||||
zmq_send(socket,nullptr,0,0);
|
||||
}
|
||||
if (nprocs > 1) MPI_Bcast(lengths,2,MPI_INT,0,world);
|
||||
|
||||
@ -135,7 +135,7 @@ void MsgZMQ::recv(int &maxheader, int *&header, int &maxbuf, char *&buf)
|
||||
|
||||
if (me == 0) {
|
||||
zmq_recv(socket,header,nheader*sizeof(int),0);
|
||||
zmq_send(socket,NULL,0,0);
|
||||
zmq_send(socket,nullptr,0,0);
|
||||
}
|
||||
if (nprocs > 1) MPI_Bcast(header,nheader,MPI_INT,0,world);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user