From f830a8b1ba44b5c3ef435f79c9c296a85e9b4d27 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 8 Nov 2019 13:07:45 -0800 Subject: [PATCH] [mle-tlvs] add LeaderDataTlv::Clear() (#4315) --- src/core/thread/mle.cpp | 4 ++-- src/core/thread/mle_tlvs.hpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 7c07754d1..3c7faea6e 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -114,8 +114,8 @@ Mle::Mle(Instance &aInstance) { otMeshLocalPrefix meshLocalPrefix; - memset(&mLeaderData, 0, sizeof(mLeaderData)); - memset(&mParentLeaderData, 0, sizeof(mParentLeaderData)); + mLeaderData.Clear(); + mParentLeaderData.Clear(); mParent.Clear(); memset(&mChildIdRequest, 0, sizeof(mChildIdRequest)); mParentCandidate.Clear(); diff --git a/src/core/thread/mle_tlvs.hpp b/src/core/thread/mle_tlvs.hpp index e54582149..b69d985e3 100644 --- a/src/core/thread/mle_tlvs.hpp +++ b/src/core/thread/mle_tlvs.hpp @@ -976,6 +976,12 @@ OT_TOOL_PACKED_BEGIN class LeaderDataTlv : public Tlv { public: + /** + * This method clears the object (setting all fields to zero). + * + */ + void Clear(void) { memset(this, 0, sizeof(*this)); } + /** * This method initializes the TLV. *