From 2d1f1ef3f5dc8ceae97950ac98587711e2241d20 Mon Sep 17 00:00:00 2001 From: lukashov Date: Fri, 11 Apr 2014 09:01:45 +0000 Subject: [PATCH] changed malloc to calloc to avoid random initialization of parameters git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5240 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- .../dlsch_channel_compensation_prec.c | 4 ++-- .../mexfiles/dlsch_channel_level_prec.c | 2 +- .../LTE_TRANSPORT/mexfiles/dlsch_decoding.c | 19 ++++++++++++++----- .../mexfiles/dlsch_detection_mrc.c | 2 +- .../mexfiles/dlsch_dual_stream_correlation.c | 2 +- .../LTE_TRANSPORT/mexfiles/dlsch_encoding.c | 4 +++- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_channel_compensation_prec.c b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_channel_compensation_prec.c index ea5e072929..98a741d04b 100644 --- a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_channel_compensation_prec.c +++ b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_channel_compensation_prec.c @@ -87,7 +87,7 @@ void mexFunction( int nlhs, mxArray *plhs[], } // Create a LTE_DL_FRAME_PARMS structure and assign required params - frame_parms = malloc(sizeof(LTE_DL_FRAME_PARMS)); + frame_parms = calloc(1,sizeof(LTE_DL_FRAME_PARMS)); tmp = mxGetField(prhs[3],0,"nb_rb"); if (tmp == NULL) { mexErrMsgTxt("Non-existing field 'nb_rb' in input argument 4."); @@ -120,7 +120,7 @@ void mexFunction( int nlhs, mxArray *plhs[], } // Create PHY_MEASUREMENTS structure and assign required params - phy_measurements = malloc(sizeof(PHY_MEASUREMENTS)); + phy_measurements = calloc(1,sizeof(PHY_MEASUREMENTS)); phy_measurements->n0_power[0] = 1; // dummy values phy_measurements->n0_power[1] = 1; phy_measurements->n0_power_tot = 1; diff --git a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_channel_level_prec.c b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_channel_level_prec.c index 15e294d687..d7f8f28732 100644 --- a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_channel_level_prec.c +++ b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_channel_level_prec.c @@ -44,7 +44,7 @@ void mexFunction( int nlhs, mxArray *plhs[], pmi_ext = (unsigned char*) mxGetData(prhs[1]); // Create a LTE_DL_FRAME_PARMS structure and assign required params - frame_parms = malloc(sizeof(LTE_DL_FRAME_PARMS)); + frame_parms = calloc(1,sizeof(LTE_DL_FRAME_PARMS)); tmp = mxGetField(prhs[2],0,"nb_rb"); if (tmp == NULL) { mexErrMsgTxt("Non-existing field 'nb_rb' in input argument 3."); diff --git a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_decoding.c b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_decoding.c index 5096f22bec..7bcf79224b 100644 --- a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_decoding.c +++ b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_decoding.c @@ -12,7 +12,7 @@ * ===============================================================================*/ -// #define DEBUG_DLSCH_DECODING +//#define DEBUG_DLSCH_DECODING void mexFunction( int mlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] @@ -85,7 +85,7 @@ void mexFunction( int mlhs, mxArray *plhs[], dlsch->current_harq_pid = harq_pid; dlsch->harq_processes[harq_pid]->rvidx = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"rvidx")); dlsch->harq_processes[harq_pid]->Nl = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Nl")); - dlsch->harq_processes[harq_pid]->Ndi = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Ndi")); + //dlsch->harq_processes[harq_pid]->Ndi = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Ndi")); dlsch->harq_processes[harq_pid]->mcs = mcs; dlsch->harq_processes[harq_pid]->rb_alloc[0] = (unsigned int) mxGetScalar(mxGetField(prhs[1],0,"rb_alloc")); dlsch->harq_processes[harq_pid]->nb_rb = (unsigned short) mxGetScalar(mxGetField(prhs[1],0,"nb_rb")); @@ -96,10 +96,10 @@ void mexFunction( int mlhs, mxArray *plhs[], num_pdcch_symbols = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"num_pdcch_symbols")); subframe = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"subframe")); - phy_vars_ue = malloc16(sizeof(PHY_VARS_UE)); + phy_vars_ue = calloc(1,sizeof(PHY_VARS_UE)); // Create a LTE_DL_FRAME_PARMS structure and assign required params - frame_parms = malloc16(sizeof(LTE_DL_FRAME_PARMS)); + frame_parms = calloc(1,sizeof(LTE_DL_FRAME_PARMS)); frame_parms->N_RB_DL = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"nb_rb")); frame_parms->frame_type = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"frame_type")); frame_parms->mode1_flag = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"mode1_flag")); @@ -108,7 +108,16 @@ void mexFunction( int mlhs, mxArray *plhs[], mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs); dlsch->harq_processes[harq_pid]->G = get_G(frame_parms,dlsch->harq_processes[harq_pid]->nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,num_pdcch_symbols,0,subframe); - + + #ifdef DEBUG_DLSCH_DECODING + mexPrintf("TBS %d\n",dlsch->harq_processes[harq_pid]->TBS); + mexPrintf("nb_rb %d\n",dlsch->harq_processes[harq_pid]->nb_rb); + mexPrintf("ncs %d\n",dlsch->harq_processes[harq_pid]->mcs); + mexPrintf("num_pdcch_symbols %d\n",num_pdcch_symbols); + mexPrintf("subframe %d\n",subframe); + mexPrintf("G %d\n",dlsch->harq_processes[harq_pid]->G); + #endif + if (dlsch->harq_processes[harq_pid]->G != mxGetM(prhs[0])) { free_ue_dlsch(dlsch); free(frame_parms); diff --git a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_detection_mrc.c b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_detection_mrc.c index 2a9d551093..2dff607a7b 100644 --- a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_detection_mrc.c +++ b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_detection_mrc.c @@ -80,7 +80,7 @@ void mexFunction( int nlhs, mxArray *plhs[], } // Create a LTE_DL_FRAME_PARMS structure and assign required params - frame_parms = malloc(sizeof(LTE_DL_FRAME_PARMS)); + frame_parms = calloc(1,sizeof(LTE_DL_FRAME_PARMS)); tmp = mxGetField(prhs[7],0,"nb_rb"); if (tmp == NULL) { diff --git a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_dual_stream_correlation.c b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_dual_stream_correlation.c index 15b880f61c..409f2c57af 100644 --- a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_dual_stream_correlation.c +++ b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_dual_stream_correlation.c @@ -56,7 +56,7 @@ void mexFunction( int nlhs, mxArray *plhs[], } // Create a LTE_DL_FRAME_PARMS structure and assign required params - frame_parms = malloc(sizeof(LTE_DL_FRAME_PARMS)); + frame_parms = calloc(1,sizeof(LTE_DL_FRAME_PARMS)); tmp = mxGetField(prhs[2],0,"nb_rb"); if (tmp == NULL) { mexErrMsgTxt("Non-existing field 'nb_rb' in input argument 3."); diff --git a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_encoding.c b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_encoding.c index 86bd0e545a..4d453ad171 100644 --- a/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_encoding.c +++ b/openair1/USERSPACE_TOOLS/MATLAB/PHY/LTE_TRANSPORT/mexfiles/dlsch_encoding.c @@ -105,12 +105,14 @@ void mexFunction( int nlhs, mxArray *plhs[], } else { dlsch->harq_processes[harq_pid]->Nl = (unsigned char) mxGetScalar(tmp); } + /* tmp = mxGetField(prhs[2],0,"Ndi"); if (tmp == NULL) { mexErrMsgTxt("Non-existing field 'Ndi' in input argument 3."); } else { dlsch->harq_processes[harq_pid]->Ndi = (unsigned char) mxGetScalar(tmp); } + */ tmp = mxGetField(prhs[1],0,"rb_alloc"); if (tmp == NULL) { mexErrMsgTxt("Non-existing field 'rb_alloc' in input argument 2."); @@ -146,7 +148,7 @@ void mexFunction( int nlhs, mxArray *plhs[], } // Create a LTE_DL_FRAME_PARMS structure and assign required params - frame_parms = malloc(sizeof(LTE_DL_FRAME_PARMS)); + frame_parms = calloc(1,sizeof(LTE_DL_FRAME_PARMS)); frame_parms->N_RB_DL = (unsigned char) dlsch->nb_rb; tmp = mxGetField(prhs[1],0,"frame_type");