This will save us some time because we do not need to
change the list in place first and then merge it.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
*network = loc_network_list_pop_first(subnets);
// Push the rest onto the stack
- loc_network_list_reverse(subnets);
- loc_network_list_merge(enumerator->stack, subnets);
+ loc_network_list_merge_reverse(enumerator->stack, subnets);
loc_network_list_unref(subnets);
loc_network_list_empty;
loc_network_list_get;
loc_network_list_merge;
+ loc_network_list_merge_reverse;
loc_network_list_new;
loc_network_list_pop;
loc_network_list_pop_first;
void loc_network_list_sort(struct loc_network_list* list);
void loc_network_list_reverse(struct loc_network_list* list);
int loc_network_list_merge(struct loc_network_list* self, struct loc_network_list* other);
+int loc_network_list_merge_reverse(struct loc_network_list* self, struct loc_network_list* other);
#endif
return 0;
}
+
+LOC_EXPORT int loc_network_list_merge_reverse(
+ struct loc_network_list* self, struct loc_network_list* other) {
+ int r;
+
+ for (int i = other->size - 1; i >= 0; i--) {
+ r = loc_network_list_push(self, other->elements[i]);
+ if (r)
+ return r;
+ }
+
+ return 0;
+}