avoid overflow when computing memory address offsets on 64-bit machines
This commit is contained in:
@ -167,8 +167,8 @@ void FixStore::write_restart(FILE *fp)
|
||||
|
||||
rbuf[0] = nrow;
|
||||
rbuf[1] = ncol;
|
||||
if (vecflag) memcpy(&rbuf[2],vstore,nrow*sizeof(double));
|
||||
else memcpy(&rbuf[2],&astore[0][0],nrow*ncol*sizeof(double));
|
||||
if (vecflag) memcpy(&rbuf[2],vstore,sizeof(double)*nrow);
|
||||
else memcpy(&rbuf[2],&astore[0][0],sizeof(double)*nrow*ncol);
|
||||
|
||||
int n = nrow*ncol + 2;
|
||||
if (comm->me == 0) {
|
||||
|
||||
@ -930,11 +930,11 @@ void Irregular::exchange_data(char *sendbuf, int nbytes, char *recvbuf)
|
||||
|
||||
// post all receives, starting after self copies
|
||||
|
||||
bigint offset = num_self*(bigint)nbytes;
|
||||
bigint offset = (bigint)num_self*(bigint)nbytes;
|
||||
for (int irecv = 0; irecv < nrecv_proc; irecv++) {
|
||||
MPI_Irecv(&recvbuf[offset],num_recv[irecv]*nbytes,MPI_CHAR,
|
||||
proc_recv[irecv],0,world,&request[irecv]);
|
||||
offset += num_recv[irecv]*nbytes;
|
||||
offset += (bigint)num_recv[irecv]*nbytes;
|
||||
}
|
||||
|
||||
// reallocate buf for largest send if necessary
|
||||
|
||||
@ -174,9 +174,9 @@ template <class T>
|
||||
void MyPoolChunk<T>::allocate(int ibin) {
|
||||
int oldpage = npage;
|
||||
npage += pagedelta;
|
||||
freelist = (int *) realloc(freelist,npage*chunkperpage*sizeof(int));
|
||||
pages = (T **) realloc(pages,npage*sizeof(T *));
|
||||
whichbin = (int *) realloc(whichbin,npage*sizeof(int));
|
||||
freelist = (int *) realloc(freelist,sizeof(int)*npage*chunkperpage);
|
||||
pages = (T **) realloc(pages,sizeof(T *)*npage);
|
||||
whichbin = (int *) realloc(whichbin,sizeof(int)*npage);
|
||||
if (!freelist || !pages) {
|
||||
errorflag = 2;
|
||||
return;
|
||||
@ -189,11 +189,11 @@ void MyPoolChunk<T>::allocate(int ibin) {
|
||||
#if defined(LAMMPS_MEMALIGN)
|
||||
void *ptr;
|
||||
if (posix_memalign(&ptr, LAMMPS_MEMALIGN,
|
||||
chunkperpage*chunksize[ibin]*sizeof(T)))
|
||||
sizeof(T)*chunkperpage*chunksize[ibin]))
|
||||
errorflag = 2;
|
||||
pages[i] = (T *) ptr;
|
||||
#else
|
||||
pages[i] = (T *) malloc(chunkperpage*chunksize[ibin]*sizeof(T));
|
||||
pages[i] = (T *) malloc(sizeof(T)*chunkperpage*chunksize[ibin]);
|
||||
if (!pages[i]) errorflag = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -195,9 +195,9 @@ void PairTable::allocate()
|
||||
memory->create(cutsq,nt,nt,"pair:cutsq");
|
||||
memory->create(tabindex,nt,nt,"pair:tabindex");
|
||||
|
||||
memset(&setflag[0][0],0,nt*nt*sizeof(int));
|
||||
memset(&cutsq[0][0],0,nt*nt*sizeof(double));
|
||||
memset(&tabindex[0][0],0,nt*nt*sizeof(int));
|
||||
memset(&setflag[0][0],0,sizeof(int)*nt*nt);
|
||||
memset(&cutsq[0][0],0,sizeof(double)*nt*nt);
|
||||
memset(&tabindex[0][0],0,sizeof(int)*nt*nt);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user