]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
network: Make lists unique
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 12 Nov 2020 14:35:43 +0000 (14:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 12 Nov 2020 14:35:43 +0000 (14:35 +0000)
Networks that are in the list won't be added again

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/network.c

index 541286db81a98b50975011cda245209bb34b20e5..44571b3f1d7e330a7ca2005c9505f05c0399ba86 100644 (file)
@@ -1103,6 +1103,10 @@ LOC_EXPORT struct loc_network* loc_network_list_get(struct loc_network_list* lis
 }
 
 LOC_EXPORT int loc_network_list_push(struct loc_network_list* list, struct loc_network* network) {
+       // Do not add networks that are already on the list
+       if (loc_network_list_contains(list, network))
+               return 0;
+
        // Check if we have space left
        if (list->size == list->max_size)
                return -ENOMEM;