Something
public text v1 · immutablestatic int check_labels(struct label_list *labels)
{
int rc = 0;
struct label_list *top = labels;
// check for and reject duplicates
void *tree;
while (labels) {
struct label **node = tsearch(labels->label, &tree,
by_label);
if (*node != labels->label) {
rc = 1;
break; // take that, district !
}
labels = labels->next;
}
// delete from tree what we added to it
while (top && tree) {
tdelete(top->label, &tree, by_label);
top = top->next;
}
return rc;
}