♻️ Clean up

This commit is contained in:
Rune Harlyk
2026-01-22 20:34:01 +01:00
committed by Rune Harlyk
parent 38bb16bb6c
commit a88c8eb0be
2 changed files with 12 additions and 34 deletions
+5 -4
View File
@@ -43,9 +43,10 @@ class CommAdapterBase {
size_t out_size;
pb_get_encoded_size(&out_size, socket_message_Message_fields, &msg_);
uint8_t *buffer = pb_heap_enc_buf;
if (out_size > sizeof(pb_heap_enc_buf)) { // If the encoded size exceeds our buffer size, we needs to malloc a buffer of a proper size
buffer = (uint8_t*) malloc(out_size);
uint8_t* buffer = pb_heap_enc_buf;
if (out_size > sizeof(pb_heap_enc_buf)) { // If the encoded size exceeds our buffer size, we needs to malloc a
// buffer of a proper size
buffer = (uint8_t*)malloc(out_size);
}
pb_ostream_t stream = pb_ostream_from_buffer(buffer, out_size);
@@ -60,7 +61,7 @@ class CommAdapterBase {
sendToSubscribers(tag, buffer, stream.bytes_written);
}
if (pb_heap_enc_buf != buffer) { // If we have malloced a buffer, free it now.
if (pb_heap_enc_buf != buffer) {
free(buffer);
}
}