summaryrefslogtreecommitdiff
path: root/gr-fec
diff options
context:
space:
mode:
authortracierenea <tracie.perez@mavs.uta.edu>2016-04-06 12:08:22 -0500
committertracierenea <tracie.perez@mavs.uta.edu>2016-04-06 12:08:22 -0500
commit1252e03f982f848082ef1e78bda922ddbedfea32 (patch)
tree224e2fcd8aa1508a912a1539537cd40a1e8e218f /gr-fec
parent0a2861d645d2d926b34246ed9077f77fe0ea408e (diff)
gr-fec: free memory for G matrix at end of constructor
There's no reason to make the G matrix a data member of this class and keep it around in memory. It's not used for encoding or decoding, so once we've used G to get G' and H, we can free that memory.
Diffstat (limited to 'gr-fec')
-rw-r--r--gr-fec/lib/ldpc_G_matrix_impl.cc13
-rw-r--r--gr-fec/lib/ldpc_G_matrix_impl.h1
2 files changed, 6 insertions, 8 deletions
diff --git a/gr-fec/lib/ldpc_G_matrix_impl.cc b/gr-fec/lib/ldpc_G_matrix_impl.cc
index 2c9469521d..8ed7969f69 100644
--- a/gr-fec/lib/ldpc_G_matrix_impl.cc
+++ b/gr-fec/lib/ldpc_G_matrix_impl.cc
@@ -51,8 +51,8 @@ namespace gr {
// Make an actual copy so we guarantee that we're not sharing
// memory with another class that reads the same alist file.
- gsl_matrix *temp_mtrx = gsl_matrix_alloc(d_num_rows, d_num_cols);
- gsl_matrix_memcpy(temp_mtrx, (gsl_matrix*)(x.get()));
+ gsl_matrix *G = gsl_matrix_alloc(d_num_rows, d_num_cols);
+ gsl_matrix_memcpy(G, (gsl_matrix*)(x.get()));
unsigned int row_index, col_index;
@@ -71,7 +71,7 @@ namespace gr {
for(row_index = 0; row_index < d_k; row_index++) {
for(col_index = 0; col_index < d_k; col_index++) {
- int value = gsl_matrix_get(temp_mtrx, row_index, col_index);
+ int value = gsl_matrix_get(G, row_index, col_index);
gsl_matrix_set(I_test, row_index, col_index, value);
}
}
@@ -97,13 +97,12 @@ namespace gr {
// Our G matrix is verified as correct, now convert it to the
// parity check matrix.
- d_G_ptr = temp_mtrx;
// Grab P matrix
gsl_matrix *P = gsl_matrix_alloc(d_k, d_n-d_k);
for(row_index = 0; row_index < d_k; row_index++) {
for(col_index = 0; col_index < d_n-d_k; col_index++) {
- int value = gsl_matrix_get(d_G_ptr, row_index, col_index + d_k);
+ int value = gsl_matrix_get(G, row_index, col_index + d_k);
gsl_matrix_set(P, row_index, col_index, value);
}
}
@@ -130,13 +129,14 @@ namespace gr {
// Calculate G transpose (used for encoding)
d_G_transp_ptr = gsl_matrix_alloc(d_n, d_k);
- gsl_matrix_transpose_memcpy(d_G_transp_ptr, d_G_ptr);
+ gsl_matrix_transpose_memcpy(d_G_transp_ptr, G);
d_H_sptr = matrix_sptr((matrix*)H_ptr);
// Free memory
gsl_matrix_free(P);
gsl_matrix_free(P_transpose);
+ gsl_matrix_free(G);
}
@@ -288,7 +288,6 @@ namespace gr {
ldpc_G_matrix_impl::~ldpc_G_matrix_impl()
{
// Call the gsl_matrix_free function to free memory.
- gsl_matrix_free(d_G_ptr);
gsl_matrix_free(d_G_transp_ptr);
}
} /* namespace code */
diff --git a/gr-fec/lib/ldpc_G_matrix_impl.h b/gr-fec/lib/ldpc_G_matrix_impl.h
index b9b119dfd5..5c2c44fef1 100644
--- a/gr-fec/lib/ldpc_G_matrix_impl.h
+++ b/gr-fec/lib/ldpc_G_matrix_impl.h
@@ -62,7 +62,6 @@ namespace gr {
// GSL matrix structure for transpose of G
gsl_matrix *d_G_transp_ptr;
- gsl_matrix *d_G_ptr;
gsl_matrix *d_H_obj;
//! Get the generator matrix (used during encoding)