gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: clean up get_num_urls function


From: gnunet
Subject: [taler-anastasis] branch master updated: clean up get_num_urls function
Date: Fri, 05 Feb 2021 17:11:05 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 3ecb525  clean up get_num_urls function
3ecb525 is described below

commit 3ecb5254b7263cff4546bae81d36f72162f6922e
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Feb 5 17:11:02 2021 +0100

    clean up get_num_urls function
---
 src/lib/anastasis_backup.c | 43 +++++++++++++------------------------------
 1 file changed, 13 insertions(+), 30 deletions(-)

diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index a88b9de..5f08a5d 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -646,55 +646,38 @@ policy_store_cb (void *cls,
  * Counts the number of different providers
  *
  * @param policies Array of policies
- * @param policies_len Length of array
+ * @param policies_len Length of @a policies array
  * @return number of different providers
  */
 static unsigned int
 get_num_urls (const struct ANASTASIS_Policy *policies[],
               unsigned int policies_len)
 {
-  unsigned int len = 0;
   unsigned int unique_urls_len = 0;
 
   if (0 == policies_len)
     return 0;
   for (unsigned int i = 0; i < policies_len; i++)
-    len += policies[i]->truths_length;
   {
-    char *provider[len];
-
-    for (unsigned int l = 0; l < policies_len; l++)
+    for (unsigned int j = 0; j < policies[i]->truths_length; j++)
     {
-      for (unsigned int j = 0; j < policies[l]->truths_length; j++)
+      bool found = false;
+
+      for (unsigned int l = 0; l < i; l++)
       {
-        int contains_url = 0;
-        if (0 < unique_urls_len)
+        for (unsigned int k = 0; k < policies[l]->truths_length; k++)
         {
-          for (unsigned int k = 0; k < unique_urls_len; k++)
+          if (0 ==
+              strcmp (policies[i]->truths[j]->url,
+                      policies[l]->truths[k]->url))
           {
-            if (NULL != provider[k])
-            {
-              if (0 ==
-                  strcmp (policies[l]->truths[j]->url, provider[k]))
-              {
-                contains_url = 1;
-                break;
-              }
-            }
+            found = true;
+            break;
           }
         }
-
-        if (0 == contains_url)
-        {
-          provider[unique_urls_len]
-            = GNUNET_strdup (policies[l]->truths[j]->url);
-          unique_urls_len++;
-        }
       }
-    }
-    for (unsigned int i = 0; i < unique_urls_len; i++)
-    {
-      GNUNET_free (provider[i]);
+      if (! found)
+        unique_urls_len++;
     }
   }
   return unique_urls_len;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]