diff --git a/include/coap/pdu.h b/include/coap/pdu.h index cd1c8c59..edd7b736 100644 --- a/include/coap/pdu.h +++ b/include/coap/pdu.h @@ -343,6 +343,17 @@ typedef uint8_t coap_proto_t; coap_pdu_t * coap_pdu_init(uint8_t type, uint8_t code, uint16_t tid, size_t size); +/** + * Dynamically grows the size of @p pdu to @p new_size. The new size + * must not exceed the PDU's configure maximum size. On success, this + * function returns 1, otherwise 0. + * + * @param pdu The PDU to resize. + * @param new_size The new size in bytes. + * @return 1 if the operation succeeded, 0 otherwise. + */ +int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size); + /** * Clears any contents from @p pdu and resets @c used_size, * and @c data pointers. @c max_size is set to @p size, any diff --git a/src/pdu.c b/src/pdu.c index e91e0f93..2c4274d3 100644 --- a/src/pdu.c +++ b/src/pdu.c @@ -150,7 +150,8 @@ coap_delete_pdu(coap_pdu_t *pdu) { } } -static int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size) { +int +coap_pdu_resize(coap_pdu_t *pdu, size_t new_size) { if (new_size > pdu->alloc_size) { uint8_t *new_hdr; size_t offset;