Commit 720d0d31 authored by Raymond Knopp's avatar Raymond Knopp

some debugging of memory leaks

parent d5e94b2c
......@@ -188,14 +188,15 @@ int8_t polar_decoder(
//Keep only the best "listSize" number of entries.
if (currentListSize > listSize) {
for (int i = 0; i < 2*listSize; i++) {
for (int i = 0; i < currentListSize; i++) {
listIndex[i]=i;
pathMetric[i] = dlist[i].pathMetric;
}
nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize);
for (int i = 0; i < 2*listSize; i++) sorted_dlist[i]=&dlist[listIndex[i]];
currentListSize = listSize;
}
stop_meas(sorting);
/*
//sort listIndex[listSize, ..., 2*listSize-1] in descending order.
uint8_t swaps, tempInd;
......@@ -275,7 +276,7 @@ int8_t polar_decoder(
}
currentListSize = listSize;
}*/
stop_meas(sorting);
}
for (int i=0; i<polarParams->crcParityBits; i++) {
......@@ -298,7 +299,9 @@ int8_t polar_decoder(
//perror("[SCL polar decoder] All list entries have failed the CRC checks.");
free(d_tilde);
for (int i=0;i<2*listSize;i++) {
// printf("error: Freeing dlist[%d].bit %p\n",i,dlist[i].bit);
nr_free_uint8_t_2D_array(dlist[i].bit, (polarParams->n+1));
// printf("error: Freeing dlist[%d].llr %p\n",i,dlist[i].bit);
nr_free_double_2D_array(dlist[i].llr, (polarParams->n+1));
free(dlist[i].crcChecksum);
}
......@@ -336,6 +339,7 @@ int8_t polar_decoder(
free(d_tilde);
for (int i=0;i<2*listSize;i++) {
// printf("correct: Freeing dlist[%d].bit %p\n",i,dlist[i].bit);
nr_free_uint8_t_2D_array(dlist[i].bit, (polarParams->n+1));
nr_free_double_2D_array(dlist[i].llr, (polarParams->n+1));
free(dlist[i].crcChecksum);
......
......@@ -159,7 +159,7 @@ void updateCrcChecksum2(decoder_list_t **dlist, uint8_t **crcGen,
uint8_t listSize, uint32_t i2, uint8_t len);
void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len);
void nr_sort_asc_double_1D_array_ind(double *matrix, int *ind, int len);
uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits);
uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits);
......
......@@ -144,14 +144,14 @@ void nr_free_double_2D_array(double **input, uint16_t xlen) {
}
// Modified Bubble Sort.
void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len) {
uint8_t swaps;
void nr_sort_asc_double_1D_array_ind(double *matrix, int *ind, int len) {
int swaps;
double temp;
uint8_t tempInd;
int tempInd;
for (uint8_t i = 0; i < len; i++) {
for (int i = 0; i < len; i++) {
swaps = 0;
for (uint8_t j = 0; j < (len - i) - 1; j++) {
for (int j = 0; j < (len - i) - 1; j++) {
if (matrix[j] > matrix[j + 1]) {
temp = matrix[j];
matrix[j] = matrix[j + 1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment