Skip to content

Commit

Permalink
Merge pull request #1519 from donaldsharp/ptm
Browse files Browse the repository at this point in the history
Ptm
  • Loading branch information
rzalamena authored Dec 7, 2017
2 parents 35f897c + a928d46 commit a457559
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/ptm_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/ptm_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ int ptm_lib_find_key_in_msg(void *, const char *, char *);
int ptm_lib_init_msg(ptm_lib_handle_t *, int, int, void *, void **);
int ptm_lib_append_msg(ptm_lib_handle_t *, void *, const char *, const char *);
int ptm_lib_complete_msg(ptm_lib_handle_t *, void *, char *, int *);
int ptm_lib_cleanup_msg(ptm_lib_handle_t *, void *);

#endif
2 changes: 2 additions & 0 deletions zebra/zebra_ptm.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ int zebra_ptm_bfd_dst_register(struct zserv *client, u_short length,
zebra_ptm_send_message(ptm_cb.out_data, data_len);

stream_failure:
ptm_lib_cleanup_msg(ptm_hdl, out_ctxt);
return 0;
}

Expand Down Expand Up @@ -946,6 +947,7 @@ int zebra_ptm_bfd_dst_deregister(struct zserv *client, u_short length,
zebra_ptm_send_message(ptm_cb.out_data, data_len);

stream_failure:
ptm_lib_cleanup_msg(ptm_hdl, out_ctxt);
return 0;
}

Expand Down

0 comments on commit a457559

Please sign in to comment.