if (!transit)
transit = XCALLOC(MTYPE_TRANSIT, sizeof(struct transit));
- if (transit->val)
- transit->val = XREALLOC(MTYPE_TRANSIT_VAL, transit->val,
- transit->length + total);
- else
- transit->val = XMALLOC(MTYPE_TRANSIT_VAL, total);
+ transit->val = XREALLOC(MTYPE_TRANSIT_VAL, transit->val,
+ transit->length + total);
memcpy(transit->val + transit->length, startp, total);
transit->length += total;
void community_add_val(struct community *com, uint32_t val)
{
com->size++;
- if (com->val)
- com->val = XREALLOC(MTYPE_COMMUNITY_VAL, com->val,
- com_length(com));
- else
- com->val = XMALLOC(MTYPE_COMMUNITY_VAL, com_length(com));
+ com->val = XREALLOC(MTYPE_COMMUNITY_VAL, com->val, com_length(com));
val = htonl(val);
memcpy(com_lastval(com), &val, sizeof(uint32_t));
struct community *community_merge(struct community *com1,
struct community *com2)
{
- if (com1->val)
- com1->val =
- XREALLOC(MTYPE_COMMUNITY_VAL, com1->val,
- (com1->size + com2->size) * COMMUNITY_SIZE);
- else
- com1->val = XMALLOC(MTYPE_COMMUNITY_VAL,
- (com1->size + com2->size) * COMMUNITY_SIZE);
+ com1->val = XREALLOC(MTYPE_COMMUNITY_VAL, com1->val,
+ (com1->size + com2->size) * COMMUNITY_SIZE);
memcpy(com1->val + com1->size, com2->val, com2->size * COMMUNITY_SIZE);
com1->size += com2->size;
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);
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);
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;
if (bgp_confederation_peers_check(bgp, as))
return -1;
- if (bgp->confed_peers)
- bgp->confed_peers =
- XREALLOC(MTYPE_BGP_CONFED_LIST, bgp->confed_peers,
- (bgp->confed_peers_cnt + 1) * sizeof(as_t));
- else
- bgp->confed_peers =
- XMALLOC(MTYPE_BGP_CONFED_LIST,
- (bgp->confed_peers_cnt + 1) * sizeof(as_t));
+ bgp->confed_peers =
+ XREALLOC(MTYPE_BGP_CONFED_LIST, bgp->confed_peers,
+ (bgp->confed_peers_cnt + 1) * sizeof(as_t));
bgp->confed_peers[bgp->confed_peers_cnt] = as;
bgp->confed_peers_cnt++;