diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2021-07-12 19:32:42 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2021-07-12 19:32:42 -0400 |
| commit | 0b04fa0e78eef6b458b0ab40a9473691cd56b64c (patch) | |
| tree | a589cf80a267ab2266670af91344e735584054de /bgpd/bgp_lcommunity.c | |
| parent | 507559a089a7ba539b90c4bb1cd0410a4b4b1345 (diff) | |
bgpd: XREALLOC handles NULL properly
the realloc man page:
If ptr is NULL, then the call is equivalent to malloc(size)
This should be sufficient for our needs to not have to have
XMALLOC and XREALLOC
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'bgpd/bgp_lcommunity.c')
| -rw-r--r-- | bgpd/bgp_lcommunity.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index fa4d4aee28..6121c4905f 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -166,12 +166,8 @@ struct lcommunity *lcommunity_dup(struct lcommunity *lcom) struct lcommunity *lcommunity_merge(struct lcommunity *lcom1, struct lcommunity *lcom2) { - if (lcom1->val) - lcom1->val = XREALLOC(MTYPE_LCOMMUNITY_VAL, lcom1->val, - lcom_length(lcom1) + lcom_length(lcom2)); - else - lcom1->val = XMALLOC(MTYPE_LCOMMUNITY_VAL, - lcom_length(lcom1) + lcom_length(lcom2)); + lcom1->val = XREALLOC(MTYPE_LCOMMUNITY_VAL, lcom1->val, + lcom_length(lcom1) + lcom_length(lcom2)); memcpy(lcom1->val + lcom_length(lcom1), lcom2->val, lcom_length(lcom2)); lcom1->size += lcom2->size; |
