diff options
author | Philip Balister <philip@opensdr.com> | 2013-07-09 12:01:25 -0400 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2013-07-09 09:56:24 -0700 |
commit | 61d88983fbe8ba7822f227efc57aa98fa287c87b (patch) | |
tree | c024d3683de741ef9e746773e23ec4a28cee8d8a | |
parent | f5b4cc0f16f8b8f11bd7f54b069ba190732e86ce (diff) |
goertzel.h : Remove the default constructor for fft::goertzel.
The default constructor does not properly initialize the class
variables. This leads to the possibilty of undefined behavior if
the class is used carelessly. Instead force the user to do the right
thing at compile time.
The patch also fixes the in-tree user of this class.
Signed-off-by: Philip Balister <philip@opensdr.com>
-rw-r--r-- | gr-analog/lib/ctcss_squelch_ff_impl.cc | 23 | ||||
-rw-r--r-- | gr-analog/lib/ctcss_squelch_ff_impl.h | 6 | ||||
-rw-r--r-- | gr-fft/include/gnuradio/fft/goertzel.h | 1 |
3 files changed, 16 insertions, 14 deletions
diff --git a/gr-analog/lib/ctcss_squelch_ff_impl.cc b/gr-analog/lib/ctcss_squelch_ff_impl.cc index 9a6f301ba0..5532c70d6f 100644 --- a/gr-analog/lib/ctcss_squelch_ff_impl.cc +++ b/gr-analog/lib/ctcss_squelch_ff_impl.cc @@ -86,15 +86,18 @@ namespace gr { else f_r = ctcss_tones[i+1]; - d_goertzel_l = fft::goertzel(rate, d_len, f_l); - d_goertzel_c = fft::goertzel(rate, d_len, freq); - d_goertzel_r = fft::goertzel(rate, d_len, f_r); + d_goertzel_l = new fft::goertzel(rate, d_len, f_l); + d_goertzel_c = new fft::goertzel(rate, d_len, freq); + d_goertzel_r = new fft::goertzel(rate, d_len, f_r); d_mute = true; } ctcss_squelch_ff_impl::~ctcss_squelch_ff_impl() { + delete d_goertzel_l; + delete d_goertzel_c; + delete d_goertzel_r; } std::vector<float> @@ -111,16 +114,16 @@ namespace gr { void ctcss_squelch_ff_impl::update_state(const float &in) { - d_goertzel_l.input(in); - d_goertzel_c.input(in); - d_goertzel_r.input(in); + d_goertzel_l->input(in); + d_goertzel_c->input(in); + d_goertzel_r->input(in); float rounder = 100000; float d_out_l, d_out_c, d_out_r; - if(d_goertzel_c.ready()) { - d_out_l = floor(rounder*abs(d_goertzel_l.output()))/rounder; - d_out_c = floor(rounder*abs(d_goertzel_c.output()))/rounder; - d_out_r = floor(rounder*abs(d_goertzel_r.output()))/rounder; + if(d_goertzel_c->ready()) { + d_out_l = floor(rounder*abs(d_goertzel_l->output()))/rounder; + d_out_c = floor(rounder*abs(d_goertzel_c->output()))/rounder; + d_out_r = floor(rounder*abs(d_goertzel_r->output()))/rounder; //printf("d_out_l=%f d_out_c=%f d_out_r=%f\n", d_out_l, d_out_c, d_out_r); d_mute = (d_out_c < d_level || d_out_c < d_out_l || d_out_c < d_out_r); diff --git a/gr-analog/lib/ctcss_squelch_ff_impl.h b/gr-analog/lib/ctcss_squelch_ff_impl.h index 8954b213e2..94ba31569f 100644 --- a/gr-analog/lib/ctcss_squelch_ff_impl.h +++ b/gr-analog/lib/ctcss_squelch_ff_impl.h @@ -38,9 +38,9 @@ namespace gr { int d_len; bool d_mute; - fft::goertzel d_goertzel_l; - fft::goertzel d_goertzel_c; - fft::goertzel d_goertzel_r; + fft::goertzel *d_goertzel_l; + fft::goertzel *d_goertzel_c; + fft::goertzel *d_goertzel_r; int find_tone(float freq); diff --git a/gr-fft/include/gnuradio/fft/goertzel.h b/gr-fft/include/gnuradio/fft/goertzel.h index 47ff1dd18c..6d9437f0fa 100644 --- a/gr-fft/include/gnuradio/fft/goertzel.h +++ b/gr-fft/include/gnuradio/fft/goertzel.h @@ -36,7 +36,6 @@ namespace gr { class FFT_API goertzel { public: - goertzel(){} goertzel(int rate, int len, float freq); void set_params(int rate, int len, float freq); |