mirror of
https://github.com/espressif/openthread.git
synced 2026-08-02 09:07:47 +00:00
[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:
committed by
Jonathan Hui
parent
dd1e0f4695
commit
b6a539c8d5
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user