From a3fba8221cb26ce43958f42dd1f58cc049c3bba6 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 16 Jun 2024 13:28:00 +0200 Subject: WIP fixing memory handling --- lib/pbdrv/drv/arduino/mod.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/pbdrv/drv') diff --git a/lib/pbdrv/drv/arduino/mod.cpp b/lib/pbdrv/drv/arduino/mod.cpp index 8766444..9130334 100644 --- a/lib/pbdrv/drv/arduino/mod.cpp +++ b/lib/pbdrv/drv/arduino/mod.cpp @@ -10,23 +10,22 @@ #include #include -#include -#include - #include "../../pb.h" #include "../../pb-mod.h" +#include "../../pb-types.h" #include "../../pb-buf.h" +#include "../../pb-mem.h" static void async_pb_i2c_recv(void * _msg, uint32_t _) { pb_buf_t * msg = (pb_buf_t *) _msg; pb_i2c_recv((uint8_t *) msg->data, msg->size); pb_buf_free(msg); - free(msg); + pb_free(msg); } static void recv_event(int bytes) { - pb_buf_t * msg = (pb_buf_t *) malloc(sizeof(pb_buf_t)); - msg->data = (char *) malloc(bytes); + pb_buf_t * msg = (pb_buf_t *) pb_malloc(sizeof(pb_buf_t)); + msg->data = (char *) pb_malloc(bytes); msg->size = 0; while (Wire.available()) msg->data[msg->size++] = Wire.read(); -- cgit v1.2.3