mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-17 10:33:49 +01:00
sys/net/unicoap: add UNICOAP_OPTIONS_ALLOC_STATIC
This commit is contained in:
parent
ec3ca22393
commit
50a5d17f50
@ -177,10 +177,12 @@ static inline void unicoap_options_clear(unicoap_options_t* options)
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#ifndef DOXYGEN
|
#ifndef DOXYGEN
|
||||||
# define _UNICOAP_OPTIONS_ALLOC(_buf, _name, capacity) \
|
# define _UNICOAP_OPTIONS_ALLOC(_buf, _name, capacity, _static) \
|
||||||
uint8_t _buf[capacity]; \
|
_static uint8_t _buf[capacity]; \
|
||||||
unicoap_options_t _name; \
|
_static unicoap_options_t _name = { \
|
||||||
unicoap_options_init(&_name, _buf, capacity);
|
.entries = { { .data = _buf } }, \
|
||||||
|
.storage_capacity = capacity, \
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,10 +192,28 @@ static inline void unicoap_options_clear(unicoap_options_t* options)
|
|||||||
* @param capacity Storage buffer capacity in bytes
|
* @param capacity Storage buffer capacity in bytes
|
||||||
*
|
*
|
||||||
* Allocates a new @ref unicoap_options_t container and a storage buffer with
|
* Allocates a new @ref unicoap_options_t container and a storage buffer with
|
||||||
* the given capacity, then calls @ref unicoap_options_t::unicoap_options_init.
|
* the given capacity, and initializes it. No need to call
|
||||||
|
* @ref unicoap_options_t::unicoap_options_init afterwards.
|
||||||
|
*
|
||||||
|
* See @ref UNICOAP_OPTIONS_ALLOC_STATIC for static allocation
|
||||||
*/
|
*/
|
||||||
#define UNICOAP_OPTIONS_ALLOC(name, capacity) \
|
#define UNICOAP_OPTIONS_ALLOC(name, capacity) \
|
||||||
_UNICOAP_OPTIONS_ALLOC(_CONCAT3(name, _storage, __LINE__), name, capacity)
|
_UNICOAP_OPTIONS_ALLOC(_CONCAT3(name, _storage, __LINE__), name, capacity,)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Statically allocates options with buffer capacity
|
||||||
|
*
|
||||||
|
* @param name Name of the variable storing the options structure
|
||||||
|
* @param capacity Static storage buffer capacity in bytes
|
||||||
|
*
|
||||||
|
* Statically allocates a new @ref unicoap_options_t container and a storage
|
||||||
|
* buffer with the given capacity, and initializes it. No need to call
|
||||||
|
* @ref unicoap_options_t::unicoap_options_init afterwards.
|
||||||
|
*
|
||||||
|
* See @ref UNICOAP_OPTIONS_ALLOC for non-static allocation
|
||||||
|
*/
|
||||||
|
#define UNICOAP_OPTIONS_ALLOC_STATIC(name, capacity) \
|
||||||
|
_UNICOAP_OPTIONS_ALLOC(_CONCAT3(name, _storage, __LINE__), name, capacity, static)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocates options with default capacity
|
* @brief Allocates options with default capacity
|
||||||
@ -201,11 +221,27 @@ static inline void unicoap_options_clear(unicoap_options_t* options)
|
|||||||
* @param name Name of the variable storing the options structure
|
* @param name Name of the variable storing the options structure
|
||||||
*
|
*
|
||||||
* Allocates a new @ref unicoap_options_t container and a storage buffer with
|
* Allocates a new @ref unicoap_options_t container and a storage buffer with
|
||||||
* @ref CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY,
|
* @ref CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY, and initializes it.
|
||||||
* then calls @ref unicoap_options_t::unicoap_options_init.
|
* No need to call @ref unicoap_options_t::unicoap_options_init afterwards.
|
||||||
|
*
|
||||||
|
* See @ref UNICOAP_OPTIONS_ALLOC_STATIC_DEFAULT for static allocation
|
||||||
*/
|
*/
|
||||||
#define UNICOAP_OPTIONS_ALLOC_DEFAULT(name) \
|
#define UNICOAP_OPTIONS_ALLOC_DEFAULT(name) \
|
||||||
UNICOAP_OPTIONS_ALLOC(name, CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY)
|
UNICOAP_OPTIONS_ALLOC(name, CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Statically allocates options with default capacity
|
||||||
|
*
|
||||||
|
* @param name Name of the variable storing the options structure
|
||||||
|
*
|
||||||
|
* Statically allocates a new @ref unicoap_options_t container and a storage buffer
|
||||||
|
* with @ref CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY, and initializes it.
|
||||||
|
* No need to call @ref unicoap_options_t::unicoap_options_init afterwards.
|
||||||
|
*
|
||||||
|
* See @ref UNICOAP_OPTIONS_ALLOC_DEFAULT for non-static allocation
|
||||||
|
*/
|
||||||
|
#define UNICOAP_OPTIONS_ALLOC_STATIC_DEFAULT(name) \
|
||||||
|
UNICOAP_OPTIONS_ALLOC_STATIC(name, CONFIG_UNICOAP_OPTIONS_BUFFER_DEFAULT_CAPACITY)
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/* MARK: - Option characteristics */
|
/* MARK: - Option characteristics */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user