mirror of
https://github.com/espressif/openthread.git
synced 2026-08-28 12:59:54 +00:00
[common] add ClearAllBytes() template function (#9818)
This commit introduces the `ClearAllBytes<ObjectType>()` template function to zero out all bytes within an object. This replaces `memset(0)` calls in OT core modules, simplifying code and improving safety by automatically using the correct object size.
This commit is contained in:
+2
-2
@@ -47,7 +47,7 @@ UdpExample::UdpExample(otInstance *aInstance, OutputImplementer &aOutputImplemen
|
||||
: Output(aInstance, aOutputImplementer)
|
||||
, mLinkSecurityEnabled(true)
|
||||
{
|
||||
memset(&mSocket, 0, sizeof(mSocket));
|
||||
ClearAllBytes(mSocket);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +258,7 @@ template <> otError UdpExample::Process<Cmd("send")>(Arg aArgs[])
|
||||
otMessageInfo messageInfo;
|
||||
otMessageSettings messageSettings = {mLinkSecurityEnabled, OT_MESSAGE_PRIORITY_NORMAL};
|
||||
|
||||
memset(&messageInfo, 0, sizeof(messageInfo));
|
||||
ClearAllBytes(messageInfo);
|
||||
|
||||
// Possible argument formats:
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user