more c89 conformance

variables should be declared at the beginning of functions
This commit is contained in:
Elad Salomons
2015-06-13 00:01:30 +03:00
parent 79fb7ab9a4
commit 82da5db7ec
3 changed files with 9 additions and 7 deletions

View File

@@ -3329,11 +3329,12 @@ int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value)
** and pattern
**----------------------------------------------------------------
*/
{ *value = 0.0;
{
int i;
*value = 0.0;
if (!Openflag) return(102);
if (index < 1 || index > Npats) return(205);
//if (period < 1 || period > Pattern[index].Length) return(251);
int i;
for (i=0; i<Pattern[index].Length; i++) {
*value+=Pattern[index].F[i];
}

View File

@@ -30,11 +30,12 @@ unsigned int _enHash(char *str);
unsigned int _enHash(char *str)
{
unsigned int hash = 5381;
unsigned int retHash;
int c;
while ((c = *str++)) {
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
}
unsigned int retHash = hash % ENHASHTABLEMAXSIZE;
retHash = hash % ENHASHTABLEMAXSIZE;
return retHash;
}

View File

@@ -237,7 +237,7 @@ int runqual(long *t)
}
else {
// stepwise calculation - hydraulic results are already in memory
for (int i=1; i<= Ntanks; ++i) {
for (i=1; i<= Ntanks; ++i) {
QTankVolumes[i-1] = Tank[i].V;
}
@@ -282,7 +282,9 @@ int nextqual(long *tstep)
{
long hydstep; /* Hydraulic solution time step */
int errcode = 0;
double *tankVolumes;
int i;
/* Determine time step */
*tstep = 0;
@@ -291,12 +293,10 @@ int nextqual(long *tstep)
if (Htime <= Dur) hydstep = Htime - Qtime;
else hydstep = 0;
double *tankVolumes;
// if we're operating in stepwise mode, capture the tank levels so we can restore them later.
if (OpenHflag) {
tankVolumes = calloc(Ntanks, sizeof(double));
for (int i=1; i<=Ntanks; ++i) {
for (i=1; i<=Ntanks; ++i) {
if (Tank[i].A != 0) { // skip reservoirs
tankVolumes[i-1] = Tank[i].V;
}