From df6452534c5ccb2340efcc81e9cebe4d134cc37e Mon Sep 17 00:00:00 2001 From: zhaohe Date: Fri, 17 May 2024 11:39:11 +0800 Subject: [PATCH] update --- src/iflytop/core/basic/zbin.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/iflytop/core/basic/zbin.hpp diff --git a/src/iflytop/core/basic/zbin.hpp b/src/iflytop/core/basic/zbin.hpp new file mode 100644 index 0000000..1fb3479 --- /dev/null +++ b/src/iflytop/core/basic/zbin.hpp @@ -0,0 +1,41 @@ +#pragma once +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace iflytop { +using namespace std; + +class ZBin { + void* m_buf = nullptr; + int m_len = 0; + + public: + ZBin(void* buf, int len) { + m_buf = (void*)malloc(len); + m_len = len; + memcpy(m_buf, buf, len); + } + + void* data() { return m_buf; } + int size() { return m_len; } + + ~ZBin() { + if (m_buf) { + free(m_buf); + m_buf = nullptr; + } + } +}; + +} // namespace iflytop \ No newline at end of file