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){
// 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;j<p->N_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);

@ -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;
}

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')
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

Loading…
Cancel
Save