From c85820204393722564a7d697cbd77b4f5aa09bea Mon Sep 17 00:00:00 2001
From: Thomas Habets <thomas@habets.se>
Date: Wed, 12 Aug 2020 11:11:11 +0100
Subject: 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).
---
 gr-digital/lib/symbol_sync_ff_impl.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

(limited to 'gr-digital/lib/symbol_sync_ff_impl.h')

diff --git a/gr-digital/lib/symbol_sync_ff_impl.h b/gr-digital/lib/symbol_sync_ff_impl.h
index f0abf56a42..d8e3164ce6 100644
--- a/gr-digital/lib/symbol_sync_ff_impl.h
+++ b/gr-digital/lib/symbol_sync_ff_impl.h
@@ -42,30 +42,30 @@ public:
                      gr_vector_void_star& output_items);
 
     // Symbol Clock Tracking and Estimation
-    float loop_bandwidth() const { return d_clock->get_loop_bandwidth(); }
-    float damping_factor() const { return d_clock->get_damping_factor(); }
-    float ted_gain() const { return d_clock->get_ted_gain(); }
-    float alpha() const { return d_clock->get_alpha(); }
-    float beta() const { return d_clock->get_beta(); }
+    float loop_bandwidth() const { return d_clock.get_loop_bandwidth(); }
+    float damping_factor() const { return d_clock.get_damping_factor(); }
+    float ted_gain() const { return d_clock.get_ted_gain(); }
+    float alpha() const { return d_clock.get_alpha(); }
+    float beta() const { return d_clock.get_beta(); }
 
     void set_loop_bandwidth(float omega_n_norm)
     {
-        d_clock->set_loop_bandwidth(omega_n_norm);
+        d_clock.set_loop_bandwidth(omega_n_norm);
     }
-    void set_damping_factor(float zeta) { d_clock->set_damping_factor(zeta); }
-    void set_ted_gain(float ted_gain) { d_clock->set_ted_gain(ted_gain); }
-    void set_alpha(float alpha) { d_clock->set_alpha(alpha); }
-    void set_beta(float beta) { d_clock->set_beta(beta); }
+    void set_damping_factor(float zeta) { d_clock.set_damping_factor(zeta); }
+    void set_ted_gain(float ted_gain) { d_clock.set_ted_gain(ted_gain); }
+    void set_alpha(float alpha) { d_clock.set_alpha(alpha); }
+    void set_beta(float beta) { d_clock.set_beta(beta); }
 
 private:
     // Timing Error Detector
-    timing_error_detector* d_ted;
+    std::unique_ptr<timing_error_detector> d_ted;
 
     // Symbol Clock Tracking and Estimation
-    clock_tracking_loop* d_clock;
+    clock_tracking_loop d_clock;
 
     // Interpolator and Interpolator Positioning and Alignment
-    interpolating_resampler_fff* d_interp;
+    std::unique_ptr<interpolating_resampler_fff> d_interp;
 
     // Block Internal Clocks
     // 4 clocks that run synchronously, aligned to the Symbol Clock:
-- 
cgit v1.2.3