summaryrefslogtreecommitdiffstats
path: root/lib/ptm_lib.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-12-05 00:59:47 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-12-05 00:59:47 +0100
commitb5f270ad0923e0e12584ca341df8fc1b11213225 (patch)
tree54dff21d96962474736116e7c254e6c8670d6510 /lib/ptm_lib.c
parentMerge pull request #1518 from opensourcerouting/clippy-issues (diff)
downloadfrr-b5f270ad0923e0e12584ca341df8fc1b11213225.tar.xz
frr-b5f270ad0923e0e12584ca341df8fc1b11213225.zip
lib: Allow memory to be cleaned up for error cases in ptm
ptm_lib.c had no way to cleanup after itself when an error was detected. This adds a function to cleanup context in such a case. A followup commit will use this new functionality. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/ptm_lib.c')
-rw-r--r--lib/ptm_lib.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/ptm_lib.c b/lib/ptm_lib.c
index e881d4922..28d26149e 100644
--- a/lib/ptm_lib.c
+++ b/lib/ptm_lib.c
@@ -223,6 +223,25 @@ int ptm_lib_init_msg(ptm_lib_handle_t *hdl, int cmd_id, int type, void *in_ctxt,
return 0;
}
+int ptm_lib_cleanup_msg(ptm_lib_handle_t *hdl, void *ctxt)
+{
+ ptm_lib_msg_ctxt_t *p_ctxt = ctxt;
+ csv_t *csv;
+
+ if (!p_ctxt) {
+ ERRLOG("%s: no context \n", __FUNCTION__);
+ return -1;
+ }
+
+ csv = p_ctxt->csv;
+
+ csv_clean(csv);
+ csv_free(csv);
+ free(p_ctxt);
+
+ return 0;
+}
+
int ptm_lib_complete_msg(ptm_lib_handle_t *hdl, void *ctxt, char *buf, int *len)
{
ptm_lib_msg_ctxt_t *p_ctxt = ctxt;