From 59d299ee3fb2d5068c38ff8b61f5b993c682e394 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 17 Oct 2022 19:24:12 +0300 Subject: code simplification --- utils/mir_signal.cpp | 10 +++++++++- utils/mir_signal.h | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/mir_signal.cpp b/utils/mir_signal.cpp index afca4f4188..d4e03e6803 100644 --- a/utils/mir_signal.cpp +++ b/utils/mir_signal.cpp @@ -37,4 +37,12 @@ SignalBuffer::~SignalBuffer() CMStringA SignalBuffer::toBase64() const { return ptrA(mir_base64_encode(m_buf->data, m_buf->len)).get(); -} \ No newline at end of file +} + +void SignalBuffer::operator=(signal_buffer *buf) +{ + if (m_buf) + signal_buffer_free(m_buf); + + m_buf = buf; +} diff --git a/utils/mir_signal.h b/utils/mir_signal.h index ef443374ff..313714edac 100644 --- a/utils/mir_signal.h +++ b/utils/mir_signal.h @@ -40,6 +40,7 @@ class SignalBuffer signal_buffer *m_buf; public: + SignalBuffer() : m_buf(nullptr) {} SignalBuffer(const class MBinBuffer &buf); SignalBuffer(const ec_public_key *key); SignalBuffer(const ec_private_key *key); @@ -47,6 +48,9 @@ public: SignalBuffer(const session_signed_pre_key *pre_key); ~SignalBuffer(); + void operator=(signal_buffer *buf); + + __forceinline operator bool() const { return m_buf != nullptr; } __forceinline uint8_t* data() const { return m_buf->data; } __forceinline unsigned len() const { return unsigned(m_buf->len); } -- cgit v1.2.3