summaryrefslogtreecommitdiff
path: root/gr-digital/lib/timing_error_detector.cc
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2020-08-12 11:11:11 +0100
committerMartin Braun <martin@gnuradio.org>2020-08-14 04:08:48 -0700
commitc85820204393722564a7d697cbd77b4f5aa09bea (patch)
tree55c5044aecd973ae5726dfd63d8fa35035cbdc86 /gr-digital/lib/timing_error_detector.cc
parentb5fb4c2eb54164ab57750878fd185b8170823711 (diff)
digital/symbol_sync: Remove manual memory management
The `cc` version already used more smart pointers, but `d_clock` didn't need to be a pointer at all. I consted function args to make it clear in the initializer that they will not be changed in the constructor body. Return value for `make` for the TED and interpolator was changed to a `unique_ptr` to make it clear that ownership is transferred. And it makes it all but impossible to accidentally memory leak. (core guidelines F.26. Also relevant I.11,R.20).
Diffstat (limited to 'gr-digital/lib/timing_error_detector.cc')
-rw-r--r--gr-digital/lib/timing_error_detector.cc39
1 files changed, 14 insertions, 25 deletions
diff --git a/gr-digital/lib/timing_error_detector.cc b/gr-digital/lib/timing_error_detector.cc
index e1ceed151e..52bb063948 100644
--- a/gr-digital/lib/timing_error_detector.cc
+++ b/gr-digital/lib/timing_error_detector.cc
@@ -14,49 +14,38 @@
#include "timing_error_detector.h"
#include <gnuradio/math.h>
+#include <boost/make_unique.hpp>
#include <stdexcept>
namespace gr {
namespace digital {
-timing_error_detector* timing_error_detector::make(enum ted_type type,
- constellation_sptr constellation)
+std::unique_ptr<timing_error_detector>
+timing_error_detector::make(enum ted_type type, constellation_sptr constellation)
{
- timing_error_detector* ret = NULL;
switch (type) {
case TED_NONE:
- break;
+ return nullptr;
case TED_MUELLER_AND_MULLER:
- ret = new ted_mueller_and_muller(constellation);
- break;
+ return boost::make_unique<ted_mueller_and_muller>(constellation);
case TED_MOD_MUELLER_AND_MULLER:
- ret = new ted_mod_mueller_and_muller(constellation);
- break;
+ return boost::make_unique<ted_mod_mueller_and_muller>(constellation);
case TED_ZERO_CROSSING:
- ret = new ted_zero_crossing(constellation);
- break;
+ return boost::make_unique<ted_zero_crossing>(constellation);
case TED_GARDNER:
- ret = new ted_gardner();
- break;
+ return boost::make_unique<ted_gardner>();
case TED_EARLY_LATE:
- ret = new ted_early_late();
- break;
+ return boost::make_unique<ted_early_late>();
case TED_DANDREA_AND_MENGALI_GEN_MSK:
- ret = new ted_generalized_msk();
- break;
+ return boost::make_unique<ted_generalized_msk>();
case TED_SIGNAL_TIMES_SLOPE_ML:
- ret = new ted_signal_times_slope_ml();
- break;
+ return boost::make_unique<ted_signal_times_slope_ml>();
case TED_SIGNUM_TIMES_SLOPE_ML:
- ret = new ted_signum_times_slope_ml();
- break;
+ return boost::make_unique<ted_signum_times_slope_ml>();
case TED_MENGALI_AND_DANDREA_GMSK:
- ret = new ted_gaussian_msk();
- break;
- default:
- break;
+ return boost::make_unique<ted_gaussian_msk>();
}
- return ret;
+ return nullptr;
}
timing_error_detector::timing_error_detector(enum ted_type type,