20 #define UNUSED_PARAM __attribute__((unused)) 45 #ifndef COAP_MAX_STRING_SIZE 46 #define COAP_MAX_STRING_SIZE 64 53 #ifndef COAP_MAX_STRINGS 54 #define COAP_MAX_STRINGS 10 57 struct coap_stringbuf_t {
58 char data[COAP_MAX_STRING_SIZE];
62 #define COAP_MAX_PACKET_SIZE (sizeof(coap_packet_t) + COAP_RXBUFFER_SIZE) 63 #ifndef COAP_MAX_PACKETS 64 #define COAP_MAX_PACKETS 2 69 char buf[COAP_MAX_PACKET_SIZE];
72 MEMB(string_storage,
struct coap_stringbuf_t, COAP_MAX_STRINGS);
73 MEMB(packet_storage, coap_packetbuf_t, COAP_MAX_PACKETS);
76 MEMB(pdu_storage,
coap_pdu_t, COAP_PDU_MAXCNT);
77 MEMB(pdu_buf_storage, coap_packetbuf_t, COAP_PDU_MAXCNT);
79 MEMB(attribute_storage,
coap_attr_t, COAP_MAX_ATTRIBUTES);
92 return &string_storage;
98 memb_init(&string_storage);
99 memb_init(&packet_storage);
100 memb_init(&node_storage);
101 memb_init(&session_storage);
102 memb_init(&pdu_storage);
103 memb_init(&pdu_buf_storage);
104 memb_init(&resource_storage);
105 memb_init(&attribute_storage);
110 struct memb *container = get_container(type);
115 if (size > container->size) {
117 "coap_malloc_type: Requested memory exceeds maximum object " 118 "size (type %d, size %d, max %d)\n",
119 type, (
int)size, container->size);
123 ptr = memb_alloc(container);
126 "coap_malloc_type: Failure (no free blocks) for type %d\n",
133 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...
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().
Pulls together all the internal only header files.