Fixed memory leak in PRACH and ZC root index table lookup

master
ismagom 10 years ago
parent f8d48961ef
commit 861d4b3985

@ -198,11 +198,11 @@ int prach_gen_seqs(prach_t *p)
if(v > v_max){ if(v > v_max){
// Get a new root sequence // Get a new root sequence
if(4 == p->f){ 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{ }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;j<p->N_zc;j++){ for(int j=0;j<p->N_zc;j++){
double phase = -M_PI*u*j*(j+1)/p->N_zc; double phase = -M_PI*u*j*(j+1)/p->N_zc;
root[j] = cexp(phase*I); root[j] = cexp(phase*I);
@ -493,8 +493,9 @@ int prach_detect(prach_t *p,
return ret; return ret;
} }
int prach_free(prach_t *p){ int prach_free(prach_t *p) {
free(p->prach_bins); free(p->prach_bins);
free(p->corr_spec);
free(p->corr); free(p->corr);
dft_plan_free(p->ifft); dft_plan_free(p->ifft);
free(p->ifft); free(p->ifft);

@ -89,7 +89,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return; 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); cf_t *signal = vec_malloc(sizeof(cf_t) * nof_samples);
if (!signal) { 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); mexutils_write_cf(signal, &plhs[0], nof_samples, 1);
} }
free(signal);
prach_free(&prach);
return; return;
} }

Binary file not shown.

@ -4,16 +4,16 @@ prachConfig=struct('Format',0,'SeqIdx',0,'PreambleIdx',0,'CyclicShiftIdx',0,'Hig
addpath('../../debug/lte/phy/lib/phch/test') 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 % FreqIdx, FreqOffset and TimeOffset need to be tested
for n_rb=1:length(NULRB) for n_rb=1:length(NULRB)
for format=0:3 for format=1:3;
for seqIdx=0:837 for seqIdx=0:17:837
fprintf('format %d, seqIdx: %d\n',format,seqIdx); fprintf('RB: %d, format %d, seqIdx: %d\n',NULRB(n_rb),format,seqIdx);
for preambleIdx=0:63 for preambleIdx=0:23:63
for CyclicShift=0:15 for CyclicShift=0:6:15
%for hs=0:1 %for hs=0:1
hs=0; hs=0;
ueConfig.NULRB=NULRB(n_rb); ueConfig.NULRB=NULRB(n_rb);
@ -22,16 +22,17 @@ for n_rb=1:length(NULRB)
prachConfig.PreambleIdx=preambleIdx; prachConfig.PreambleIdx=preambleIdx;
prachConfig.CyclicShiftIdx=CyclicShift; prachConfig.CyclicShiftIdx=CyclicShift;
prachConfig.HighSpeed=hs; prachConfig.HighSpeed=hs;
prachConfig.FreqIdx=5;
[mat, info]=ltePRACH(ueConfig,prachConfig); prachConfig.FreqOffest=5;
lib=liblte_prach(ueConfig,prachConfig); lib=liblte_prach(ueConfig,prachConfig);
err=mean(abs(mat(:)-lib(:)));
if (err > 10^-3) [mat, info]=ltePRACH(ueConfig,prachConfig);
disp(err) err=mean(abs(mat(:)-lib(1:length(mat))));
error('Error!'); if (err > 10^-3)
end disp(err)
% end error('Error!');
end
%end
end end
end end
end end

Loading…
Cancel
Save