Skip to content

Commit

Permalink
Merge pull request #14802 from Keelan10/fix-nht-leak
Browse files Browse the repository at this point in the history
sharpd: Set Callback Function for Memory Cleanup
  • Loading branch information
donaldsharp authored Nov 15, 2023
2 parents 3c4d64d + 9dd86de commit 4cce1e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions sharpd/sharp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static void sharp_global_init(void)
{
memset(&sg, 0, sizeof(sg));
sg.nhs = list_new();
sg.nhs->del = (void (*)(void *))sharp_nh_tracker_free;
sg.ted = NULL;
sg.srv6_locators = list_new();
}
Expand Down
5 changes: 5 additions & 0 deletions sharpd/sharp_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ struct sharp_nh_tracker *sharp_nh_tracker_get(struct prefix *p)
return nht;
}

void sharp_nh_tracker_free(struct sharp_nh_tracker *nht)
{
XFREE(MTYPE_NH_TRACKER, nht);
}

void sharp_nh_tracker_dump(struct vty *vty)
{
struct listnode *node;
Expand Down
1 change: 1 addition & 0 deletions sharpd/sharp_nht.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct sharp_nh_tracker {
};

extern struct sharp_nh_tracker *sharp_nh_tracker_get(struct prefix *p);
extern void sharp_nh_tracker_free(struct sharp_nh_tracker *nht);

extern void sharp_nh_tracker_dump(struct vty *vty);

Expand Down

0 comments on commit 4cce1e4

Please sign in to comment.