aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepcompress.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-11-30 01:58:45 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-11-30 13:33:16 -0500
commit7cb71df02cbe417798067a4f68a62dcbca8be025 (patch)
tree0a556bf2d5bbd15045c3347017353bc092412002 /klippy/stepcompress.c
parent55fc11ff024958bb86331bfafc5abc11a82a48fe (diff)
downloadkutter-7cb71df02cbe417798067a4f68a62dcbca8be025.tar.gz
kutter-7cb71df02cbe417798067a4f68a62dcbca8be025.tar.xz
kutter-7cb71df02cbe417798067a4f68a62dcbca8be025.zip
mcu: Be careful to free memory allocated in C code
Free steppersync, stepcompress, and commandqueue objects. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/stepcompress.c')
-rw-r--r--klippy/stepcompress.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c
index b00dd7c3..732afe99 100644
--- a/klippy/stepcompress.c
+++ b/klippy/stepcompress.c
@@ -290,6 +290,17 @@ stepcompress_alloc(uint32_t max_error, uint32_t queue_step_msgid
return sc;
}
+// Free memory associated with a 'stepcompress' object
+void
+stepcompress_free(struct stepcompress *sc)
+{
+ if (!sc)
+ return;
+ free(sc->queue);
+ message_queue_free(&sc->msg_queue);
+ free(sc);
+}
+
// Convert previously scheduled steps into commands for the mcu
static void
stepcompress_flush(struct stepcompress *sc, uint64_t move_clock)
@@ -573,6 +584,18 @@ steppersync_alloc(struct serialqueue *sq, struct stepcompress **sc_list
return ss;
}
+// Free memory associated with a 'steppersync' object
+void
+steppersync_free(struct steppersync *ss)
+{
+ if (!ss)
+ return;
+ free(ss->sc_list);
+ free(ss->move_clocks);
+ serialqueue_free_commandqueue(ss->cq);
+ free(ss);
+}
+
// Implement a binary heap algorithm to track when the next available
// 'struct move' in the mcu will be available
static void