community_free, lcommunity_free and ecommunity_free are similar type of functions. Most of the places, these three are called together. The signature of community_free is different from other two functions. Modified the community_free API signature to align with other two functions to avoid any confusion. There is no functionality impact with this and this is just to avoid any confusion.
Testing: manual testing and show commands
Signed-off-by: Sri Mohana Singamsetty msingamsetty@vmware.com
aspath_free(new->aspath);
if (new->community != old->community)
- community_free(new->community);
+ community_free(&new->community);
if (new->ecommunity != old->ecommunity)
ecommunity_free(&new->ecommunity);
aspath_free(attr->aspath);
attr->aspath = NULL;
}
- if (attr->community && !attr->community->refcnt) {
- community_free(attr->community);
- attr->community = NULL;
- }
-
+ if (attr->community && !attr->community->refcnt)
+ community_free(&attr->community);
if (attr->ecommunity && !attr->ecommunity->refcnt)
ecommunity_free(&attr->ecommunity);
if (attr->lcommunity && !attr->lcommunity->refcnt)
switch (entry->style) {
case COMMUNITY_LIST_STANDARD:
if (entry->u.com)
- community_free(entry->u.com);
+ community_free(&entry->u.com);
break;
case LARGE_COMMUNITY_LIST_STANDARD:
if (entry->u.lcom)
if (com) {
entry = community_list_entry_lookup(list, com, direct);
- community_free(com);
+ community_free(&com);
} else
entry = community_list_entry_lookup(list, str, direct);
}
/* Free communities value. */
-void community_free(struct community *com)
+void community_free(struct community **com)
{
- if (com->val)
- XFREE(MTYPE_COMMUNITY_VAL, com->val);
- if (com->str)
- XFREE(MTYPE_COMMUNITY_STR, com->str);
-
- if (com->json) {
- json_object_free(com->json);
- com->json = NULL;
+ if ((*com)->val)
+ XFREE(MTYPE_COMMUNITY_VAL, (*com)->val);
+ if ((*com)->str)
+ XFREE(MTYPE_COMMUNITY_STR, (*com)->str);
+
+ if ((*com)->json) {
+ json_object_free((*com)->json);
+ (*com)->json = NULL;
}
- XFREE(MTYPE_COMMUNITY, com);
+ XFREE(MTYPE_COMMUNITY, (*com));
}
/* Add one community value to the community. */
/* Arguemnt com is allocated temporary. So when it is not used in
hash, it should be freed. */
if (find != com)
- community_free(com);
+ community_free(&com);
/* Increment refrence counter. */
find->refcnt++;
ret = (struct community *)hash_release(comhash, *com);
assert(ret != NULL);
- community_free(*com);
- *com = NULL;
+ community_free(com);
}
}
break;
case community_token_unknown:
if (com)
- community_free(com);
+ community_free(&com);
return NULL;
}
} while (str);
com_sort = community_uniq_sort(com);
- community_free(com);
+ community_free(&com);
return com_sort;
}
/* Prototypes of communities attribute functions. */
extern void community_init(void);
extern void community_finish(void);
-extern void community_free(struct community *);
+extern void community_free(struct community **comm);
extern struct community *community_uniq_sort(struct community *);
extern struct community *community_parse(uint32_t *, unsigned short);
extern struct community *community_intern(struct community *);
mpinfo->attr->community);
community =
community_uniq_sort(commerge);
- community_free(commerge);
+ community_free(&commerge);
} else
community = community_dup(
mpinfo->attr->community);
merge = community_merge(community_dup(old), gshut);
if (old->refcnt == 0)
- community_free(old);
+ community_free(&old);
new = community_uniq_sort(merge);
- community_free(merge);
+ community_free(&merge);
} else {
new = community_dup(gshut);
}
- community_free(gshut);
+ community_free(&gshut);
attr->community = new;
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
if (aspath)
aspath_free(aspath);
if (community)
- community_free(community);
+ community_free(&community);
if (ecommunity)
ecommunity_free(&ecommunity);
if (lcommunity)
community, pi->attr->community);
community =
community_uniq_sort(commerge);
- community_free(commerge);
+ community_free(&commerge);
} else
community = community_dup(
pi->attr->community);
pinew->attr->community);
community =
community_uniq_sort(commerge);
- community_free(commerge);
+ community_free(&commerge);
} else
community = community_dup(
pinew->attr->community);
if (aspath)
aspath_free(aspath);
if (community)
- community_free(community);
+ community_free(&community);
if (ecommunity)
ecommunity_free(&ecommunity);
if (lcommunity)
(exact ? bgp_show_type_community_exact
: bgp_show_type_community),
com, use_json);
- community_free(com);
+ community_free(&com);
return ret;
}
attr->community = NULL;
/* See the longer comment down below. */
if (old && old->refcnt == 0)
- community_free(old);
+ community_free(&old);
return RMAP_OKAY;
}
merge = community_merge(community_dup(old), rcs->com);
new = community_uniq_sort(merge);
- community_free(merge);
+ community_free(&merge);
} else
new = community_dup(rcs->com);
* Really need to cleanup attribute caching sometime.
*/
if (old && old->refcnt == 0)
- community_free(old);
+ community_free(&old);
/* will be interned by caller if required */
attr->community = new;
struct rmap_com_set *rcs = rule;
if (rcs->com)
- community_free(rcs->com);
+ community_free(&rcs->com);
XFREE(MTYPE_ROUTE_MAP_COMPILED, rcs);
}
merge = community_list_match_delete(community_dup(old),
list);
new = community_uniq_sort(merge);
- community_free(merge);
+ community_free(&merge);
/* HACK: if the old community is not intern'd,
* we should free it here, or all reference to it may be
* Really need to cleanup attribute caching sometime.
*/
if (old->refcnt == 0)
- community_free(old);
+ community_free(&old);
if (new->size == 0) {
path->attr->community = NULL;
path->attr->flag &=
~ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
- community_free(new);
+ community_free(&new);
} else {
path->attr->community = new;
path->attr->flag |=
ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
"community", str);
- community_free(com);
+ community_free(&com);
return ret;
}