summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/math
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2020-04-10 17:40:11 +0100
committerMarcus Müller <marcus@hostalia.de>2020-04-11 01:41:39 +0200
commitb5e8a552c09a1b9a1397e731cc6f54d427df9a67 (patch)
treedc60d92c7f53d5d15cbf42d2c5a2623a557eb7ca /gnuradio-runtime/lib/math
parent616879745ce5d61e6acd54ad84d60359a739a27d (diff)
runtime: Remove most manual memory management
The remaining ones: * `pmt_pool.cc`, which is a memory allocator so that makes sense * the tricky and aptly named `sptr_magic.cc`.
Diffstat (limited to 'gnuradio-runtime/lib/math')
-rw-r--r--gnuradio-runtime/lib/math/qa_fxpt_nco.cc10
-rw-r--r--gnuradio-runtime/lib/math/qa_fxpt_vco.cc30
2 files changed, 18 insertions, 22 deletions
diff --git a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
index dd6bc2cb9f..1259dd6f9a 100644
--- a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
+++ b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
@@ -72,8 +72,8 @@ BOOST_AUTO_TEST_CASE(t1)
{
gr::nco<float, float> ref_nco;
gr::fxpt_nco new_nco;
- gr_complex* ref_block = new gr_complex[SIN_COS_BLOCK_SIZE];
- gr_complex* new_block = new gr_complex[SIN_COS_BLOCK_SIZE];
+ std::vector<gr_complex> ref_block(SIN_COS_BLOCK_SIZE);
+ std::vector<gr_complex> new_block(SIN_COS_BLOCK_SIZE);
double max_error = 0;
ref_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
@@ -81,8 +81,8 @@ BOOST_AUTO_TEST_CASE(t1)
BOOST_CHECK(std::abs(ref_nco.get_freq() - new_nco.get_freq()) <= SIN_COS_TOLERANCE);
- ref_nco.sincos((gr_complex*)ref_block, SIN_COS_BLOCK_SIZE);
- new_nco.sincos((gr_complex*)new_block, SIN_COS_BLOCK_SIZE);
+ ref_nco.sincos((gr_complex*)ref_block.data(), SIN_COS_BLOCK_SIZE);
+ new_nco.sincos((gr_complex*)new_block.data(), SIN_COS_BLOCK_SIZE);
for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++) {
BOOST_CHECK(std::abs(ref_block[i].real() - new_block[i].real()) <=
@@ -96,6 +96,4 @@ BOOST_AUTO_TEST_CASE(t1)
BOOST_CHECK(std::abs(ref_nco.get_phase() - new_nco.get_phase()) <= SIN_COS_TOLERANCE);
// printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error,
// max_phase_error);
- delete[] ref_block;
- delete[] new_block;
}
diff --git a/gnuradio-runtime/lib/math/qa_fxpt_vco.cc b/gnuradio-runtime/lib/math/qa_fxpt_vco.cc
index 49af65609d..2cd8a4733b 100644
--- a/gnuradio-runtime/lib/math/qa_fxpt_vco.cc
+++ b/gnuradio-runtime/lib/math/qa_fxpt_vco.cc
@@ -64,17 +64,19 @@ BOOST_AUTO_TEST_CASE(t1)
{
gr::vco<float, float> ref_vco;
gr::fxpt_vco new_vco;
- float* ref_block = new float[SIN_COS_BLOCK_SIZE];
- float* new_block = new float[SIN_COS_BLOCK_SIZE];
- float* input = new float[SIN_COS_BLOCK_SIZE];
+ std::vector<float> ref_block(SIN_COS_BLOCK_SIZE);
+ std::vector<float> new_block(SIN_COS_BLOCK_SIZE);
+ std::vector<float> input(SIN_COS_BLOCK_SIZE);
double max_error = 0;
for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++) {
input[i] = sin(double(i));
}
- ref_vco.cos(ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);
- new_vco.cos(new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);
+ ref_vco.cos(
+ ref_block.data(), input.data(), SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);
+ new_vco.cos(
+ new_block.data(), input.data(), SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);
for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++) {
BOOST_CHECK(std::abs(ref_block[i] - new_block[i]) <= SIN_COS_TOLERANCE);
@@ -83,9 +85,6 @@ BOOST_AUTO_TEST_CASE(t1)
BOOST_CHECK(std::abs(ref_vco.get_phase() - new_vco.get_phase()) <= SIN_COS_TOLERANCE);
// printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error,
// ref_vco.get_phase()-new_vco.get_phase());
- delete[] ref_block;
- delete[] new_block;
- delete[] input;
}
@@ -93,17 +92,19 @@ BOOST_AUTO_TEST_CASE(t2)
{
gr::vco<gr_complex, float> ref_vco;
gr::fxpt_vco new_vco;
- gr_complex* ref_block = new gr_complex[SIN_COS_BLOCK_SIZE];
- gr_complex* new_block = new gr_complex[SIN_COS_BLOCK_SIZE];
- float* input = new float[SIN_COS_BLOCK_SIZE];
+ std::vector<gr_complex> ref_block(SIN_COS_BLOCK_SIZE);
+ std::vector<gr_complex> new_block(SIN_COS_BLOCK_SIZE);
+ std::vector<float> input(SIN_COS_BLOCK_SIZE);
double max_error = 0;
for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++) {
input[i] = sin(double(i));
}
- ref_vco.sincos(ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);
- new_vco.sincos(new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);
+ ref_vco.sincos(
+ ref_block.data(), input.data(), SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);
+ new_vco.sincos(
+ new_block.data(), input.data(), SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);
for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++) {
BOOST_CHECK(std::abs(ref_block[i] - new_block[i]) <= SIN_COS_TOLERANCE);
@@ -112,7 +113,4 @@ BOOST_AUTO_TEST_CASE(t2)
BOOST_CHECK(std::abs(ref_vco.get_phase() - new_vco.get_phase()) <= SIN_COS_TOLERANCE);
// printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error,
// ref_vco.get_phase()-new_vco.get_phase());
- delete[] ref_block;
- delete[] new_block;
- delete[] input;
}