summaryrefslogtreecommitdiff
path: root/gr-digital/lib
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2021-02-28 22:42:10 +0000
committermormj <34754695+mormj@users.noreply.github.com>2021-03-01 07:52:44 -0500
commit9649eeb70f2b8bd0f863a007be64c6570915b053 (patch)
tree80929191fed286e7b0146b23812f033905322a18 /gr-digital/lib
parent371ea71315877db109a6924c6840dfa8f82c76c5 (diff)
digital/hdlc_deframer: Remove manual memory management
Signed-off-by: Thomas Habets <thomas@habets.se>
Diffstat (limited to 'gr-digital/lib')
-rw-r--r--gr-digital/lib/hdlc_deframer_bp_impl.cc13
-rw-r--r--gr-digital/lib/hdlc_deframer_bp_impl.h8
2 files changed, 9 insertions, 12 deletions
diff --git a/gr-digital/lib/hdlc_deframer_bp_impl.cc b/gr-digital/lib/hdlc_deframer_bp_impl.cc
index 3ceba38281..d394f19ed7 100644
--- a/gr-digital/lib/hdlc_deframer_bp_impl.cc
+++ b/gr-digital/lib/hdlc_deframer_bp_impl.cc
@@ -33,20 +33,17 @@ hdlc_deframer_bp_impl::hdlc_deframer_bp_impl(int length_min, int length_max)
gr::io_signature::make(0, 0, 0)),
d_length_min(length_min),
d_length_max(length_max),
+ d_pktbuf(length_max + 2),
d_port(pmt::mp("out"))
{
set_output_multiple(length_max * 2);
message_port_register_out(d_port);
- d_bytectr = 0;
- d_bitctr = 0;
- d_ones = 0;
- d_pktbuf = new unsigned char[length_max + 2];
}
/*
* Our virtual destructor.
*/
-hdlc_deframer_bp_impl::~hdlc_deframer_bp_impl() { delete[] d_pktbuf; }
+hdlc_deframer_bp_impl::~hdlc_deframer_bp_impl() {}
unsigned int hdlc_deframer_bp_impl::crc_ccitt(unsigned char* data, size_t len)
{
@@ -80,10 +77,10 @@ int hdlc_deframer_bp_impl::work(int noutput_items,
int len = d_bytectr - 2; // make Coverity happy
unsigned short crc =
d_pktbuf[d_bytectr - 1] << 8 | d_pktbuf[d_bytectr - 2];
- unsigned short calc_crc = crc_ccitt(d_pktbuf, len);
+ unsigned short calc_crc = crc_ccitt(d_pktbuf.data(), len);
if (crc == calc_crc) {
- pmt::pmt_t pdu(
- pmt::cons(pmt::PMT_NIL, pmt::make_blob(d_pktbuf, len)));
+ pmt::pmt_t pdu(pmt::cons(pmt::PMT_NIL,
+ pmt::make_blob(d_pktbuf.data(), len)));
message_port_pub(d_port, pdu);
} else {
}
diff --git a/gr-digital/lib/hdlc_deframer_bp_impl.h b/gr-digital/lib/hdlc_deframer_bp_impl.h
index 68bd001989..9dc7e6f244 100644
--- a/gr-digital/lib/hdlc_deframer_bp_impl.h
+++ b/gr-digital/lib/hdlc_deframer_bp_impl.h
@@ -21,10 +21,10 @@ class hdlc_deframer_bp_impl : public hdlc_deframer_bp
private:
size_t d_length_min;
size_t d_length_max;
- size_t d_ones;
- size_t d_bytectr;
- size_t d_bitctr;
- unsigned char* d_pktbuf;
+ size_t d_ones = 0;
+ size_t d_bytectr = 0;
+ size_t d_bitctr = 0;
+ std::vector<unsigned char> d_pktbuf;
const pmt::pmt_t d_port;