libcoap
4.2.1
|
#include <stdlib.h>
Go to the source code of this file.
Enumerations | |
enum | coap_memory_tag_t { COAP_STRING, COAP_ATTRIBUTE_NAME, COAP_ATTRIBUTE_VALUE, COAP_PACKET, COAP_NODE, COAP_CONTEXT, COAP_ENDPOINT, COAP_PDU, COAP_PDU_BUF, COAP_RESOURCE, COAP_RESOURCEATTR, COAP_SESSION, COAP_OPTLIST } |
Type specifiers for coap_malloc_type(). More... | |
Functions | |
void | coap_memory_init (void) |
Initializes libcoap's memory management. More... | |
void * | coap_malloc_type (coap_memory_tag_t type, size_t size) |
Allocates a chunk of size bytes and returns a pointer to the newly allocated memory. More... | |
void | coap_free_type (coap_memory_tag_t type, void *p) |
Releases the memory that was allocated by coap_malloc_type(). More... | |
COAP_STATIC_INLINE void * | coap_malloc (size_t size) |
Wrapper function to coap_malloc_type() for backwards compatibility. More... | |
COAP_STATIC_INLINE void | coap_free (void *object) |
Wrapper function to coap_free_type() for backwards compatibility. More... | |
enum coap_memory_tag_t |
Type specifiers for coap_malloc_type().
Memory objects can be typed to facilitate arrays of type objects to be used instead of dynamic memory management on constrained devices.
Enumerator | |
---|---|
COAP_STRING | |
COAP_ATTRIBUTE_NAME | |
COAP_ATTRIBUTE_VALUE | |
COAP_PACKET | |
COAP_NODE | |
COAP_CONTEXT | |
COAP_ENDPOINT | |
COAP_PDU | |
COAP_PDU_BUF | |
COAP_RESOURCE | |
COAP_RESOURCEATTR | |
COAP_SESSION | |
COAP_OPTLIST |
COAP_STATIC_INLINE void coap_free | ( | void * | object | ) |
Wrapper function to coap_free_type() for backwards compatibility.
Definition at line 82 of file mem.h.
void coap_free_type | ( | coap_memory_tag_t | type, |
void * | p | ||
) |
Releases the memory that was allocated by coap_malloc_type().
The type tag type
must be the same that was used for allocating the object pointed to by .
type | The type of the object to release. |
p | A pointer to memory that was allocated by coap_malloc_type(). |
COAP_STATIC_INLINE void* coap_malloc | ( | size_t | size | ) |
Wrapper function to coap_malloc_type() for backwards compatibility.
Definition at line 75 of file mem.h.
void* coap_malloc_type | ( | coap_memory_tag_t | type, |
size_t | size | ||
) |
Allocates a chunk of size
bytes and returns a pointer to the newly allocated memory.
The type
is used to select the appropriate storage container on constrained devices. The storage allocated by coap_malloc_type() must be released with coap_free_type().
type | The type of object to be stored. |
size | The number of bytes requested. |
NULL
on error. void coap_memory_init | ( | void | ) |
Initializes libcoap's memory management.
This function must be called once before coap_malloc() can be used on constrained devices.