- set *un = NULL ;
- set *lp ;
-
- /* add all elements in the first list */
- for (lp = list1 ; lp ; lp = lp->next )
- addSet(&un,lp->item);
-
- /* now for all those in list2 which does not */
- /* already exist in the list add */
- for (lp = list2 ; lp ; lp = lp->next )
- if (!isinSet(un,lp->item))
- addSet (&un,lp->item);
-
- switch (throw) {
- case THROW_SRC :
- setToNull ((void **)&list2);
- break;
- case THROW_DEST :
- setToNull ((void **)&list1);
- break;
- case THROW_BOTH :
- setToNull ((void **)&list1);
- setToNull ((void **)&list2);
+ if (*sset == NULL) {
+ *sset = list;
+ }
+ else {
+ set *lp;
+
+ for (lp = *sset; lp->next; lp = lp->next)
+ ;
+ lp->next = list;
+ }
+}
+
+/*-----------------------------------------------------------------*/
+/* unionSets - will return the union of the two lists */
+/*-----------------------------------------------------------------*/
+set *
+unionSets (set * list1, set * list2, int throw)
+{
+ set *un = NULL;
+ set *lp;
+
+ /* add all elements in the first list */
+ for (lp = list1; lp; lp = lp->next)
+ addSet (&un, lp->item);
+
+ /* now for all those in list2 which does not */
+ /* already exist in the list add */
+ for (lp = list2; lp; lp = lp->next)
+ if (!isinSet (un, lp->item))
+ addSet (&un, lp->item);
+
+ switch (throw)
+ {
+ case THROW_SRC:
+ setToNull ((void *) &list2);
+ break;
+ case THROW_DEST:
+ setToNull ((void *) &list1);
+ break;
+ case THROW_BOTH:
+ setToNull ((void *) &list1);
+ setToNull ((void *) &list2);