10 #include "coap_config.h" 28 #define UNUSED_PARAM __attribute__((unused)) 47 #define COAP_MAX_STRING_SIZE 12 48 #define COAP_MAX_STRINGS 8 50 struct coap_string_t {
51 char data[COAP_MAX_STRING_SIZE];
54 #include "coap_config.h" 60 #define COAP_MAX_PACKET_SIZE (sizeof(coap_packet_t) + COAP_MAX_PDU_SIZE) 61 #define COAP_MAX_PACKETS 2 65 char buf[COAP_MAX_PACKET_SIZE];
68 MEMB(string_storage,
struct coap_string_t, COAP_MAX_STRINGS);
69 MEMB(packet_storage, coap_packetbuf_t, COAP_MAX_PACKETS);
71 MEMB(pdu_storage,
coap_pdu_t, COAP_PDU_MAXCNT);
72 MEMB(pdu_buf_storage, coap_packetbuf_t, COAP_PDU_MAXCNT);
74 MEMB(attribute_storage,
coap_attr_t, COAP_MAX_ATTRIBUTES);
86 return &string_storage;
92 memb_init(&string_storage);
93 memb_init(&packet_storage);
94 memb_init(&node_storage);
95 memb_init(&pdu_storage);
96 memb_init(&pdu_buf_storage);
97 memb_init(&resource_storage);
98 memb_init(&attribute_storage);
103 struct memb *container = get_container(type);
107 if (size > container->size) {
108 debug(
"coap_malloc_type: Requested memory exceeds maximum object size\n");
112 return memb_alloc(container);
117 memb_free(get_container(type),
object);
coap_memory_tag_t
Type specifiers for coap_malloc_type().
Header structure for CoAP PDUs.
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.
void coap_memory_init(void)
Initializes libcoap's memory management.
socklen_t size
size of addr
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().