mirror of
https://github.com/espressif/openthread.git
synced 2026-08-16 23:57:46 +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
@@ -219,7 +219,7 @@ template <> otError TcpExample::Process<Cmd("init")>(Arg aArgs[])
|
||||
{
|
||||
otTcpEndpointInitializeArgs endpointArgs;
|
||||
|
||||
memset(&endpointArgs, 0x00, sizeof(endpointArgs));
|
||||
ClearAllBytes(endpointArgs);
|
||||
endpointArgs.mEstablishedCallback = HandleTcpEstablishedCallback;
|
||||
if (mUseCircularSendBuffer)
|
||||
{
|
||||
@@ -241,7 +241,7 @@ template <> otError TcpExample::Process<Cmd("init")>(Arg aArgs[])
|
||||
{
|
||||
otTcpListenerInitializeArgs listenerArgs;
|
||||
|
||||
memset(&listenerArgs, 0x00, sizeof(listenerArgs));
|
||||
ClearAllBytes(listenerArgs);
|
||||
listenerArgs.mAcceptReadyCallback = HandleTcpAcceptReadyCallback;
|
||||
listenerArgs.mAcceptDoneCallback = HandleTcpAcceptDoneCallback;
|
||||
listenerArgs.mContext = this;
|
||||
|
||||
Reference in New Issue
Block a user