From 00ee059bf8661038dbd0bf953b7f22f16f740728 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Date: Wed, 13 Sep 2023 08:04:38 +0200 Subject: [PATCH] fix: Uses caps allocation for data buffer instead of item struct Once introduced the memory destination for outbox was incorrectly allocating the outbox data structuture instead of data buffer to the selected memory. --- lib/mqtt_outbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mqtt_outbox.c b/lib/mqtt_outbox.c index 879ad35..2623904 100644 --- a/lib/mqtt_outbox.c +++ b/lib/mqtt_outbox.c @@ -41,7 +41,7 @@ outbox_handle_t outbox_init(void) outbox_item_handle_t outbox_enqueue(outbox_handle_t outbox, outbox_message_handle_t message, outbox_tick_t tick) { - outbox_item_handle_t item = heap_caps_calloc(1, sizeof(outbox_item_t), MQTT_OUTBOX_MEMORY); + outbox_item_handle_t item = calloc(1, sizeof(outbox_item_t)); ESP_MEM_CHECK(TAG, item, return NULL); item->msg_id = message->msg_id; item->msg_type = message->msg_type; @@ -49,7 +49,7 @@ outbox_item_handle_t outbox_enqueue(outbox_handle_t outbox, outbox_message_handl item->tick = tick; item->len = message->len + message->remaining_len; item->pending = QUEUED; - item->buffer = malloc(message->len + message->remaining_len); + item->buffer = heap_caps_malloc(message->len + message->remaining_len, MQTT_OUTBOX_MEMORY); ESP_MEM_CHECK(TAG, item->buffer, { free(item); return NULL;