From 4e1a34704dc08d0279e78c275989f10f85fd6cc2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 11 May 2020 13:50:30 +0800 Subject: [PATCH] MsgHdr add Destroy --- cpp/protoutils.cc | 8 ++++++++ cpp/protoutils.h | 1 + 2 files changed, 9 insertions(+) diff --git a/cpp/protoutils.cc b/cpp/protoutils.cc index 5459715..4c4c6d8 100644 --- a/cpp/protoutils.cc +++ b/cpp/protoutils.cc @@ -23,6 +23,14 @@ namespace f8 return hdr; } + void MsgHdr::Destroy(MsgHdr* hdr) + { + if (hdr->buf) { + free((void*)hdr->buf); + } + free((void*)hdr); + } + int Net_GetMessageId(::google::protobuf::Message& msg) { std::string msgname; diff --git a/cpp/protoutils.h b/cpp/protoutils.h index 859e578..9902cc7 100644 --- a/cpp/protoutils.h +++ b/cpp/protoutils.h @@ -94,6 +94,7 @@ namespace f8 const void* user_data = nullptr; MsgHdr* Clone(); + static void Destroy(MsgHdr* hdr); }; #ifdef MATCHVS