diff --git a/src/core/common/code_utils.hpp b/src/core/common/code_utils.hpp index 118f1a0ae..2c32aca60 100644 --- a/src/core/common/code_utils.hpp +++ b/src/core/common/code_utils.hpp @@ -49,6 +49,19 @@ */ #define OT_ARRAY_LENGTH(aArray) (sizeof(aArray) / sizeof(aArray[0])) +/** + * This macro returns a pointer to end of a given array (pointing to the past-the-end element). + * + * Note that the past-the-end element is a theoretical element that would follow the last element in the array. It does + * not point to an actual element in array, and thus should not be dereferenced. + * + * @param[in] Name of the array variable + * + * @returns Pointer to the past-the-end element. + * + */ +#define OT_ARRAY_END(aArray) (&aArray[OT_ARRAY_LENGTH(aArray)]) + /** * This macro returns a pointer aligned by @p aAlignment. *