mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[common] add GetArrayLength() and GetArrayEnd() (#7413)
This commit adds two inline template functions to get the length of an array and a pointer to the end of the array. These functions replace similar macros that were used with OT core modules. The template functions are safer to use since they would perform type checking at compile time. The functions validate that the input variable is indeed an array and unlike the macros they will not work with a pointer variable.
This commit is contained in:
committed by
GitHub
parent
49918c7f8e
commit
7ec658e47a
@@ -34,6 +34,7 @@
|
||||
#include "notifier.hpp"
|
||||
|
||||
#include "border_router/routing_manager.hpp"
|
||||
#include "common/array.hpp"
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/debug.hpp"
|
||||
#include "common/locator_getters.hpp"
|
||||
@@ -289,7 +290,7 @@ const char *Notifier::EventToString(Event aEvent) const
|
||||
"PndDset", // kEventPendingDatasetChanged (1 << 29)
|
||||
};
|
||||
|
||||
for (uint8_t index = 0; index < OT_ARRAY_LENGTH(kEventStrings); index++)
|
||||
for (uint8_t index = 0; index < GetArrayLength(kEventStrings); index++)
|
||||
{
|
||||
if (static_cast<uint32_t>(aEvent) == (1U << index))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user