XFREE (MTYPE_ZCLIENT, zclient);
}
-int
+u_short *
redist_check_instance (struct redist_proto *red, u_short instance)
{
struct listnode *node;
u_short *id;
if (!red->instances)
- return 0;
+ return NULL;
for (ALL_LIST_ELEMENTS_RO (red->instances, node, id))
if (*id == instance)
- return 1;
+ return id;
- return 0;
+ return NULL;
}
void
if (!red->instances)
red->instances = list_new();
- in = (u_short *)calloc(1, sizeof(u_short));
+ in = calloc (1, sizeof(u_short));
*in = instance;
listnode_add (red->instances, in);
}
void
redist_del_instance (struct redist_proto *red, u_short instance)
{
- struct listnode *node;
- u_short *id = NULL;
+ u_short *id;
- if (!red->instances)
+ id = redist_check_instance (red, instance);
+ if (! id)
return;
- for (ALL_LIST_ELEMENTS_RO (red->instances, node, id))
- if (*id == instance)
- break;
-
- if (id)
+ listnode_delete(red->instances, id);
+ if (!red->instances->count)
{
- listnode_delete(red->instances, id);
- if (!red->instances->count)
- {
- red->enabled = 0;
- list_free(red->instances);
- red->instances = NULL;
- }
+ red->enabled = 0;
+ list_free(red->instances);
+ red->instances = NULL;
}
}
extern void zclient_serv_path_set (char *path);
extern const char *zclient_serv_path_get (void);
-extern int redist_check_instance (struct redist_proto *, u_short);
+extern u_short *redist_check_instance (struct redist_proto *, u_short);
extern void redist_add_instance (struct redist_proto *, u_short);
extern void redist_del_instance (struct redist_proto *, u_short);
* withdraw them when necessary.
*/
if (instance)
- {
- if (redist_check_instance (&client->mi_redist[afi][type], instance))
- redist_del_instance (&client->mi_redist[afi][type], instance);
- }
+ redist_del_instance (&client->mi_redist[afi][type], instance);
else
vrf_bitmap_unset (client->redist[afi][type], zvrf->vrf_id);
}