[code-utils] add OT_ARRAY_END() macro (#3722)

This commit adds `OT_ARRAY_END(aArray)` macro which returns a
pointer to the end of a given array (pointing to the past-the-end
element).
This commit is contained in:
Abtin Keshavarzian
2019-04-02 10:20:22 -07:00
committed by Jonathan Hui
parent dd1e0f4695
commit b6a539c8d5
+13
View File
@@ -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.
*