mirror of
https://github.com/espressif/openthread.git
synced 2026-08-17 07:59: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:
@@ -31,6 +31,7 @@
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include "test_util.h"
|
||||
#include "common/array.hpp"
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/instance.hpp"
|
||||
#include "thread/child_table.hpp"
|
||||
@@ -290,7 +291,7 @@ void TestChildTable(void)
|
||||
},
|
||||
};
|
||||
|
||||
const uint16_t testListLength = OT_ARRAY_LENGTH(testChildList);
|
||||
const uint16_t testListLength = GetArrayLength(testChildList);
|
||||
|
||||
uint16_t testNumAllowedChildren = 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user