summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_ecommunity.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-07-13 01:32:42 +0200
committerDonald Sharp <sharpd@nvidia.com>2021-07-13 01:32:42 +0200
commit0b04fa0e78eef6b458b0ab40a9473691cd56b64c (patch)
treea589cf80a267ab2266670af91344e735584054de /bgpd/bgp_ecommunity.c
parentMerge pull request #9027 from ton31337/fix/missing_unlock_bgp_dest (diff)
downloadfrr-0b04fa0e78eef6b458b0ab40a9473691cd56b64c.tar.xz
frr-0b04fa0e78eef6b458b0ab40a9473691cd56b64c.zip
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_ecommunity.c')
-rw-r--r--bgpd/bgp_ecommunity.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index 923c9b0d7..3a951e6e8 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -158,7 +158,6 @@ static bool ecommunity_add_val_internal(struct ecommunity *ecom,
ecom->val = XREALLOC(MTYPE_ECOMMUNITY_VAL, ecom->val,
ecom_length_size(ecom, ecom_size));
-
memmove(ecom->val + ((ins_idx + 1) * ecom_size),
ecom->val + (ins_idx * ecom_size),
(ecom->size - 1 - ins_idx) * ecom_size);
@@ -287,14 +286,9 @@ char *ecommunity_str(struct ecommunity *ecom)
struct ecommunity *ecommunity_merge(struct ecommunity *ecom1,
struct ecommunity *ecom2)
{
- if (ecom1->val)
- ecom1->val = XREALLOC(MTYPE_ECOMMUNITY_VAL, ecom1->val,
- (size_t)(ecom1->size + ecom2->size)
- * (size_t)ecom1->unit_size);
- else
- ecom1->val = XMALLOC(MTYPE_ECOMMUNITY_VAL,
- (size_t)(ecom1->size + ecom2->size)
- * (size_t)ecom1->unit_size);
+ ecom1->val = XREALLOC(MTYPE_ECOMMUNITY_VAL, ecom1->val,
+ (size_t)(ecom1->size + ecom2->size)
+ * (size_t)ecom1->unit_size);
memcpy(ecom1->val + (ecom1->size * ecom1->unit_size), ecom2->val,
(size_t)ecom2->size * (size_t)ecom1->unit_size);