Soletta™ Framework
|
Operations specific to SOL_MEMDESC_TYPE_ARRAY. More...
#include <sol-memdesc.h>
Data Fields | |
uint16_t | api_version |
API version, must match SOL_MEMDESC_OPS_ARRAY_API_VERSION at runtime. More... | |
void *(* | get_element )(const struct sol_memdesc *desc, const void *memory, size_t idx) |
get memory of the given array item. More... | |
ssize_t(* | get_length )(const struct sol_memdesc *desc, const void *memory) |
calculate array length. More... | |
int(* | resize )(const struct sol_memdesc *desc, void *memory, size_t length) |
resize array length. More... | |
Operations specific to SOL_MEMDESC_TYPE_ARRAY.
This provides array-specific operations to use when dealing with a memory description.
uint16_t sol_memdesc_ops_array::api_version |
API version, must match SOL_MEMDESC_OPS_ARRAY_API_VERSION at runtime.
void*(* sol_memdesc_ops_array::get_element)(const struct sol_memdesc *desc, const void *memory, size_t idx) |
get memory of the given array item.
Will be used to get the array element by its index. Return should be the memory pointer or NULL on error (then set errno accordingly).
ssize_t(* sol_memdesc_ops_array::get_length)(const struct sol_memdesc *desc, const void *memory) |
calculate array length.
Will be used to calculate the array length. Return should be number of items, each defined in struct sol_memdesc::array_item.
On error, negative errno is returned.
int(* sol_memdesc_ops_array::resize)(const struct sol_memdesc *desc, void *memory, size_t length) |
resize array length.
Will be used to resize the array length. The given size should be number of items, each defined in struct sol_memdesc::array_item.
When implementing, always remember to free the items that are not needed anymore when the new length is smaller than the old. Failing to do so will lead to memory leaks.
On error, negative errno is returned.