aboutsummaryrefslogtreecommitdiff
path: root/lib/pbdrv/pb-serial.c
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-16 13:28:00 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-16 13:28:00 +0200
commita3fba8221cb26ce43958f42dd1f58cc049c3bba6 (patch)
tree2afca47358d1e7d4f425c3944285d36231f8711d /lib/pbdrv/pb-serial.c
parent30171b5c84dd90ee9de9f3efc395766497a86c85 (diff)
WIP fixing memory handling
Diffstat (limited to 'lib/pbdrv/pb-serial.c')
-rw-r--r--lib/pbdrv/pb-serial.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/pbdrv/pb-serial.c b/lib/pbdrv/pb-serial.c
index 29a307c..689db0c 100644
--- a/lib/pbdrv/pb-serial.c
+++ b/lib/pbdrv/pb-serial.c
@@ -48,7 +48,7 @@ void pb_ser_w_cmd_prop(mpack_writer_t * writer, const pb_msg_t * _msg) {
mpack_write_bin(writer, (char *) cmd->value, cmd->_value_size);
}
void pb_ser_r_cmd_prop(mpack_reader_t * reader, pb_msg_t * _msg) {
- pb_cmd_prop_t * cmd = _msg->cmd = malloc(sizeof(pb_cmd_prop_t));
+ pb_cmd_prop_t * cmd = _msg->cmd = pb_malloc(sizeof(pb_cmd_prop_t));
cmd->propid = mpack_expect_u8(reader);
cmd->_value_size = mpack_expect_bin(reader);
@@ -62,7 +62,7 @@ void pb_ser_free_cmd_prop(pb_msg_t * _msg) {
MPACK_FREE(cmd->value);
cmd->value = NULL;
}
- free(_msg->cmd);
+ pb_free(_msg->cmd);
_msg->cmd = NULL;
}
}
@@ -73,13 +73,13 @@ void pb_ser_w_cmd_state(mpack_writer_t * writer, const pb_msg_t * _msg) {
mpack_write_u8(writer, cmd->state);
}
void pb_ser_r_cmd_state(mpack_reader_t * reader, pb_msg_t * _msg) {
- pb_cmd_state_t * cmd = _msg->cmd = malloc(sizeof(pb_cmd_state_t));
+ pb_cmd_state_t * cmd = _msg->cmd = pb_malloc(sizeof(pb_cmd_state_t));
cmd->state = mpack_expect_u8(reader);
}
void pb_ser_free_cmd_state(pb_msg_t * _msg) {
if (_msg->cmd != NULL) {
- free(_msg->cmd);
+ pb_free(_msg->cmd);
_msg->cmd = NULL;
}
}
@@ -90,7 +90,7 @@ void pb_ser_w_cmd_magic(mpack_writer_t * writer, const pb_msg_t * _msg) {
mpack_write_bin(writer, (char *) cmd->magic, cmd->_magic_size);
}
void pb_ser_r_cmd_magic(mpack_reader_t * reader, pb_msg_t * _msg) {
- pb_cmd_magic_t * cmd = _msg->cmd = malloc(sizeof(pb_cmd_magic_t));
+ pb_cmd_magic_t * cmd = _msg->cmd = pb_malloc(sizeof(pb_cmd_magic_t));
cmd->_magic_size = mpack_expect_bin(reader);
cmd->magic = mpack_read_bytes_alloc(reader, cmd->_magic_size);
@@ -103,7 +103,7 @@ void pb_ser_free_cmd_magic(pb_msg_t * _msg) {
MPACK_FREE(cmd->magic);
cmd->magic = NULL;
}
- free(_msg->cmd);
+ pb_free(_msg->cmd);
_msg->cmd = NULL;
}
}