forked from lijiext/lammps
apply corrections to issues reported by static code analysis
This commit is contained in:
parent
477ddaf112
commit
7b89e47a38
|
@ -36,7 +36,7 @@ class FixHalt : public Fix {
|
|||
|
||||
private:
|
||||
int attribute,operation,eflag,ivar;
|
||||
double attvalue,value;
|
||||
double value;
|
||||
char *idvar;
|
||||
|
||||
double bondmax();
|
||||
|
|
|
@ -578,34 +578,21 @@ void Region::write_restart(FILE *fp)
|
|||
|
||||
int Region::restart(char *buf, int &n)
|
||||
{
|
||||
int sizeid = buf[n];
|
||||
int size = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
char *restart_id = new char[sizeid];
|
||||
for (int i = 0; i < sizeid; i++)
|
||||
restart_id[i] = buf[n++];
|
||||
if (strcmp(restart_id,id) != 0) return 0;
|
||||
if ((size <= 0) || (strcmp(buf+n,id) != 0)) return 0;
|
||||
n += size;
|
||||
|
||||
int sizestyle = buf[n];
|
||||
size = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
char *restart_style = new char[sizestyle];
|
||||
for (int i = 0; i < sizestyle; i++)
|
||||
restart_style[i] = buf[n++];
|
||||
if (strcmp(restart_style,style) != 0) return 0;
|
||||
if ((size <= 0) || (strcmp(buf+n,style) != 0)) return 0;
|
||||
n += size;
|
||||
|
||||
int restart_nreg = buf[n];
|
||||
int restart_nreg = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
if (restart_nreg != nregion) return 0;
|
||||
|
||||
char *rlist = new char[size_restart*sizeof(double)];
|
||||
for (int i = 0; i < size_restart*sizeof(double); i++)
|
||||
rlist[i] = buf[n++];
|
||||
for (int i = 0; i < size_restart; i++){
|
||||
prev[i] = ((double *)rlist)[i];
|
||||
}
|
||||
|
||||
delete [] rlist;
|
||||
delete [] restart_id;
|
||||
delete [] restart_style;
|
||||
memcpy(prev,buf+n,size_restart*sizeof(double));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -323,30 +323,23 @@ void RegIntersect::write_restart(FILE *fp)
|
|||
|
||||
int RegIntersect::restart(char *buf, int& n)
|
||||
{
|
||||
int sizeid = buf[n];
|
||||
int size = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
char *restart_id = new char[sizeid];
|
||||
for (int i = 0; i < sizeid; i++)
|
||||
restart_id[i] = buf[n++];
|
||||
if (strcmp(restart_id,id) != 0) return 0;
|
||||
if ((size <= 0) || (strcmp(buf+n,id) != 0)) return 0;
|
||||
n += size;
|
||||
|
||||
int sizestyle = buf[n];
|
||||
size = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
if ((size <= 0) || (strcmp(buf+n,style) != 0)) return 0;
|
||||
n += size;
|
||||
|
||||
char *restart_style = new char[sizestyle];
|
||||
for (int i = 0; i < sizestyle; i++)
|
||||
restart_style[i] = buf[n++];
|
||||
if (strcmp(restart_style,style) != 0) return 0;
|
||||
|
||||
int restart_nreg = buf[n];
|
||||
int restart_nreg = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
if (restart_nreg != nregion) return 0;
|
||||
|
||||
for (int ilist = 0; ilist < nregion; ilist++){
|
||||
if (!domain->regions[list[ilist]]->restart(buf, n)){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (int ilist = 0; ilist < nregion; ilist++)
|
||||
if (!domain->regions[list[ilist]]->restart(buf, n)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -315,27 +315,23 @@ void RegUnion::write_restart(FILE *fp)
|
|||
|
||||
int RegUnion::restart(char *buf, int &n)
|
||||
{
|
||||
int sizeid = buf[n];
|
||||
int size = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
char *restart_id = new char[sizeid];
|
||||
for (int i = 0; i < sizeid; i++)
|
||||
restart_id[i] = buf[n++];
|
||||
if (strcmp(restart_id,id) != 0) return 0;
|
||||
if ((size <= 0) || (strcmp(buf+n,id) != 0)) return 0;
|
||||
n += size;
|
||||
|
||||
int sizestyle = buf[n];
|
||||
size = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
char *restart_style = new char[sizestyle];
|
||||
for (int i = 0; i < sizestyle; i++)
|
||||
restart_style[i] = buf[n++];
|
||||
if (strcmp(restart_style,style) != 0) return 0;
|
||||
if ((size <= 0) || (strcmp(buf+n,style) != 0)) return 0;
|
||||
n += size;
|
||||
|
||||
int restart_nreg = buf[n];
|
||||
int restart_nreg = *((int *)(buf+n));
|
||||
n += sizeof(int);
|
||||
if (restart_nreg != nregion) return 0;
|
||||
|
||||
for (int ilist = 0; ilist < nregion; ilist++){
|
||||
for (int ilist = 0; ilist < nregion; ilist++)
|
||||
if (!domain->regions[list[ilist]]->restart(buf, n)) return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue