X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=trp%2Ftrp_rtable.c;h=6cc8e18f4bcca1cbd5ec8247e18627193d7c166b;hb=53ab8fd0668d83134baf386020069e81085d13a2;hp=97bf92311520224e79ba530bb2aa3bad0e83e125;hpb=043c9f3f1f33523515547f60f53ac7310e0da3e4;p=trust_router.git diff --git a/trp/trp_rtable.c b/trp/trp_rtable.c index 97bf923..6cc8e18 100644 --- a/trp/trp_rtable.c +++ b/trp/trp_rtable.c @@ -529,15 +529,17 @@ static char *timespec_to_str(struct timespec *ts) TRP_RENTRY *trp_rtable_get_selected_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm) { - size_t n_entries=0; - TRP_RENTRY *entry=trp_rtable_get_realm_entries(rtbl, apc, realm, &n_entries); - if (n_entries==0) - return NULL; + size_t n=0; + TRP_RENTRY **entry=trp_rtable_get_realm_entries(rtbl, apc, realm, &n); + TRP_RENTRY *selected=NULL; - while((entry!=NULL) && (!trp_rentry_get_selected(entry))) - entry=trp_rentry_get_next(entry); + if (n==0) + return NULL; - return entry; + while(n-- && !trp_rentry_get_selected(entry[n])) { } + selected=entry[n]; + talloc_free(entry); + return selected; } /* Pretty print a route table entry to a newly allocated string. If sep is NULL,