Move some arrays to heap storage.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5656 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Steven Franke 2015-07-01 19:33:40 +00:00
parent 5250e0765a
commit 15618e4b16
2 changed files with 30 additions and 10 deletions

View File

@ -22,7 +22,7 @@ LIBS = -lfftw3 -lm
all: wsprd wsprsim wsprd_exp all: wsprd wsprsim wsprd_exp
DEPS = wsprsim_utils.h wsprd_utils.h fano.h DEPS = wsprsim_utils.h wsprd_utils.h fano.h
OBJS1 = wsprd.o wsprd_utils.o tab.o fano.o nhash.o OBJS1 = wsprd.o wsprd_utils.o wsprsim_utils.o tab.o fano.o nhash.o
wsprd: $(OBJS1) wsprd: $(OBJS1)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS) $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS)

View File

@ -392,15 +392,23 @@ void subtract_signal2(double *id, double *qd, long np,
double pi=4.*atan(1.0), twopidt, phi=0, dphi, cs; double pi=4.*atan(1.0), twopidt, phi=0, dphi, cs;
int i, j, k, ii, nsym=162, nspersym=256, nfilt=256; //nfilt must be even number. int i, j, k, ii, nsym=162, nspersym=256, nfilt=256; //nfilt must be even number.
int nsig=nsym*nspersym; int nsig=nsym*nspersym;
int nc2=45000;
double refi[45000],refq[45000]; double *refi, *refq, *ci, *cq, *cfi, *cfq;
double ci[45000],cq[45000],cfi[45000],cfq[45000];
memset(refi,0,sizeof(double)*45000); refi=malloc(sizeof(double)*nc2);
memset(refq,0,sizeof(double)*45000); refq=malloc(sizeof(double)*nc2);
memset(ci,0,sizeof(double)*45000); ci=malloc(sizeof(double)*nc2);
memset(cq,0,sizeof(double)*45000); cq=malloc(sizeof(double)*nc2);
memset(cfi,0,sizeof(double)*45000); cfi=malloc(sizeof(double)*nc2);
memset(cfq,0,sizeof(double)*45000); cfq=malloc(sizeof(double)*nc2);
memset(refi,0,sizeof(double)*nc2);
memset(refq,0,sizeof(double)*nc2);
memset(ci,0,sizeof(double)*nc2);
memset(cq,0,sizeof(double)*nc2);
memset(cfi,0,sizeof(double)*nc2);
memset(cfq,0,sizeof(double)*nc2);
twopidt=2.0*pi*dt; twopidt=2.0*pi*dt;
@ -487,6 +495,14 @@ void subtract_signal2(double *id, double *qd, long np,
qd[k]=qd[k] - (cfi[j]*refq[i]+cfq[j]*refi[i])/norm; qd[k]=qd[k] - (cfi[j]*refq[i]+cfq[j]*refi[i])/norm;
} }
} }
free(refi);
free(refq);
free(ci);
free(cq);
free(cfi);
free(cfq);
return; return;
} }
@ -494,13 +510,16 @@ unsigned long writec2file(char *c2filename, int trmin, double freq
, double *idat, double *qdat) , double *idat, double *qdat)
{ {
int i; int i;
float buffer[2*45000]; float *buffer;
buffer=malloc(sizeof(float)*2*45000);
memset(buffer,0,sizeof(float)*2*45000); memset(buffer,0,sizeof(float)*2*45000);
FILE *fp; FILE *fp;
fp = fopen(c2filename,"wb"); fp = fopen(c2filename,"wb");
if( fp == NULL ) { if( fp == NULL ) {
fprintf(stderr, "Could not open c2 file '%s'\n", c2filename); fprintf(stderr, "Could not open c2 file '%s'\n", c2filename);
free(buffer);
return 0; return 0;
} }
unsigned long nwrite = fwrite(c2filename,sizeof(char),14,fp); unsigned long nwrite = fwrite(c2filename,sizeof(char),14,fp);
@ -516,6 +535,7 @@ unsigned long writec2file(char *c2filename, int trmin, double freq
if( nwrite == 2*45000 ) { if( nwrite == 2*45000 ) {
return nwrite; return nwrite;
} else { } else {
free(buffer);
return 0; return 0;
} }
} }