10 #include "coap_config.h" 29 #define UNUSED_PARAM __attribute__((unused)) 54 #ifndef COAP_MAX_STRING_SIZE 55 #define COAP_MAX_STRING_SIZE 64 62 #ifndef COAP_MAX_STRINGS 63 #define COAP_MAX_STRINGS 10 66 struct coap_stringbuf_t {
67 char data[COAP_MAX_STRING_SIZE];
70 #include "coap_config.h" 77 #define COAP_MAX_PACKET_SIZE (sizeof(coap_packet_t) + COAP_RXBUFFER_SIZE) 78 #ifndef COAP_MAX_PACKETS 79 #define COAP_MAX_PACKETS 2 84 char buf[COAP_MAX_PACKET_SIZE];
87 MEMB(string_storage,
struct coap_stringbuf_t, COAP_MAX_STRINGS);
88 MEMB(packet_storage, coap_packetbuf_t, COAP_MAX_PACKETS);
91 MEMB(pdu_storage,
coap_pdu_t, COAP_PDU_MAXCNT);
92 MEMB(pdu_buf_storage, coap_packetbuf_t, COAP_PDU_MAXCNT);
94 MEMB(attribute_storage,
coap_attr_t, COAP_MAX_ATTRIBUTES);
107 return &string_storage;
113 memb_init(&string_storage);
114 memb_init(&packet_storage);
115 memb_init(&node_storage);
116 memb_init(&session_storage);
117 memb_init(&pdu_storage);
118 memb_init(&pdu_buf_storage);
119 memb_init(&resource_storage);
120 memb_init(&attribute_storage);
125 struct memb *container = get_container(type);
130 if (size > container->size) {
132 "coap_malloc_type: Requested memory exceeds maximum object " 133 "size (type %d, size %d, max %d)\n",
134 type, (
int)size, container->size);
138 ptr = memb_alloc(container);
141 "coap_malloc_type: Failure (no free blocks) for type %d\n",
148 memb_free(get_container(type),
object);
coap_memory_tag_t
Type specifiers for coap_malloc_type().
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
Generic resource handling.
Pre-defined constants that reflect defaults for CoAP.
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.
#define coap_log(level,...)
Logging function.
void coap_memory_init(void)
Initializes libcoap's memory management.
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().