From 861d4b3985a2aecca9825cae4c5c750b62861795 Mon Sep 17 00:00:00 2001 From: ismagom Date: Mon, 16 Feb 2015 18:53:36 +0100 Subject: [PATCH] Fixed memory leak in PRACH and ZC root index table lookup --- lte/phy/lib/phch/src/prach.c | 9 +++---- lte/phy/lib/phch/test/prach_test_mex.c | 6 ++++- matlab/tests/octave-workspace | Bin 607 -> 0 bytes matlab/tests/prach_test.m | 31 +++++++++++++------------ 4 files changed, 26 insertions(+), 20 deletions(-) delete mode 100644 matlab/tests/octave-workspace diff --git a/lte/phy/lib/phch/src/prach.c b/lte/phy/lib/phch/src/prach.c index b3009956e..6a0fa51dc 100644 --- a/lte/phy/lib/phch/src/prach.c +++ b/lte/phy/lib/phch/src/prach.c @@ -198,11 +198,11 @@ int prach_gen_seqs(prach_t *p) if(v > v_max){ // Get a new root sequence if(4 == p->f){ - u = prach_zc_roots_format4[p->rsi + p->N_roots]; + u = prach_zc_roots_format4[(p->rsi + p->N_roots)%138]; }else{ - u = prach_zc_roots[p->rsi + p->N_roots]; + u = prach_zc_roots[(p->rsi + p->N_roots)%838]; } - + printf("Seq#%d, u: %3d (rsi: %d, n_roots: %d\n", i, u, p->rsi, p->N_roots); for(int j=0;jN_zc;j++){ double phase = -M_PI*u*j*(j+1)/p->N_zc; root[j] = cexp(phase*I); @@ -493,8 +493,9 @@ int prach_detect(prach_t *p, return ret; } -int prach_free(prach_t *p){ +int prach_free(prach_t *p) { free(p->prach_bins); + free(p->corr_spec); free(p->corr); dft_plan_free(p->ifft); free(p->ifft); diff --git a/lte/phy/lib/phch/test/prach_test_mex.c b/lte/phy/lib/phch/test/prach_test_mex.c index ed8eac9f9..5a73b3eac 100644 --- a/lte/phy/lib/phch/test/prach_test_mex.c +++ b/lte/phy/lib/phch/test/prach_test_mex.c @@ -89,7 +89,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - uint32_t nof_samples = lte_sampling_freq_hz(n_ul_rb) * 0.001; + uint32_t nof_samples = lte_sampling_freq_hz(n_ul_rb) * 0.003; cf_t *signal = vec_malloc(sizeof(cf_t) * nof_samples); if (!signal) { @@ -107,6 +107,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexutils_write_cf(signal, &plhs[0], nof_samples, 1); } + free(signal); + + prach_free(&prach); + return; } diff --git a/matlab/tests/octave-workspace b/matlab/tests/octave-workspace deleted file mode 100644 index f32a4d28288c294ec92bc1af20e10c675eea8747..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 607 zcmaiyO-{ow5QU8pKjm-Dk_&Xf35sYGfmBjNV2xa7oLF+2)NxR`H76jvNwZAMVjTPB z%Z%qu*2>E-n%~b?;!+4vJE@9gwbdraNr>(mOQWQf?ym8!RsI~pDI%_1DLpoT_&P9ARHs&C}P(RW5Cd~8Rk0rMPHr&5Bmo~eu8TN diff --git a/matlab/tests/prach_test.m b/matlab/tests/prach_test.m index e8099b2f8..a9a5652ac 100644 --- a/matlab/tests/prach_test.m +++ b/matlab/tests/prach_test.m @@ -4,16 +4,16 @@ prachConfig=struct('Format',0,'SeqIdx',0,'PreambleIdx',0,'CyclicShiftIdx',0,'Hig addpath('../../debug/lte/phy/lib/phch/test') -NULRB=[6 15 25 50 100]; +NULRB=[15 25 50 100]; % FreqIdx, FreqOffset and TimeOffset need to be tested for n_rb=1:length(NULRB) - for format=0:3 - for seqIdx=0:837 - fprintf('format %d, seqIdx: %d\n',format,seqIdx); - for preambleIdx=0:63 - for CyclicShift=0:15 + for format=1:3; + for seqIdx=0:17:837 + fprintf('RB: %d, format %d, seqIdx: %d\n',NULRB(n_rb),format,seqIdx); + for preambleIdx=0:23:63 + for CyclicShift=0:6:15 %for hs=0:1 hs=0; ueConfig.NULRB=NULRB(n_rb); @@ -22,16 +22,17 @@ for n_rb=1:length(NULRB) prachConfig.PreambleIdx=preambleIdx; prachConfig.CyclicShiftIdx=CyclicShift; prachConfig.HighSpeed=hs; - - [mat, info]=ltePRACH(ueConfig,prachConfig); - + prachConfig.FreqIdx=5; + prachConfig.FreqOffest=5; lib=liblte_prach(ueConfig,prachConfig); - err=mean(abs(mat(:)-lib(:))); - if (err > 10^-3) - disp(err) - error('Error!'); - end - % end + + [mat, info]=ltePRACH(ueConfig,prachConfig); + err=mean(abs(mat(:)-lib(1:length(mat)))); + if (err > 10^-3) + disp(err) + error('Error!'); + end + %end end end end