gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r37896 - gnunet/src/rps


From: gnunet
Subject: [GNUnet-SVN] r37896 - gnunet/src/rps
Date: Tue, 6 Sep 2016 16:05:44 +0200

Author: ch3
Date: 2016-09-06 16:05:44 +0200 (Tue, 06 Sep 2016)
New Revision: 37896

Modified:
   gnunet/src/rps/gnunet-service-rps_sampler.c
   gnunet/src/rps/gnunet-service-rps_sampler_elem.c
   gnunet/src/rps/gnunet-service-rps_sampler_elem.h
   gnunet/src/rps/test_rps.c
Log:
-rps: proper destruction of sampler elements

Modified: gnunet/src/rps/gnunet-service-rps_sampler.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps_sampler.c 2016-09-06 14:05:40 UTC (rev 
37895)
+++ gnunet/src/rps/gnunet-service-rps_sampler.c 2016-09-06 14:05:44 UTC (rev 
37896)
@@ -327,7 +327,7 @@
                "-%" PRIu32 ": %s",
                i,
                sampler->sampler_elements[i]->file_name);
-      GNUNET_free (sampler->sampler_elements[i]);
+      RPS_sampler_elem_destroy (sampler->sampler_elements[i]);
     }
 
     GNUNET_array_grow (sampler->sampler_elements,

Modified: gnunet/src/rps/gnunet-service-rps_sampler_elem.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps_sampler_elem.c    2016-09-06 14:05:40 UTC 
(rev 37895)
+++ gnunet/src/rps/gnunet-service-rps_sampler_elem.c    2016-09-06 14:05:44 UTC 
(rev 37896)
@@ -99,6 +99,24 @@
 
 
 /**
+ * Destroy a sampler element.
+ *
+ * @param sampler_elem the element to destroy
+ */
+void
+RPS_sampler_elem_destroy (struct RPS_SamplerElement *sampler_elem)
+{
+  #ifdef TO_FILE
+  if (NULL != sampler_elem->file_name)
+  {
+    GNUNET_free (sampler_elem->file_name);
+  }
+  #endif /* TO_FILE */
+  GNUNET_free (sampler_elem);
+}
+
+
+/**
  * Input an PeerID into the given sampler element.
  *
  * @param sampler the sampler the @a s_elem belongs to.
@@ -112,9 +130,11 @@
 
   s_elem->num_peers++;
 
+  #ifdef TO_FILE
   to_file (s_elem->file_name,
            "Got id %s",
            GNUNET_i2s_full (other));
+  #endif /* TO_FILE */
 
   if (0 == GNUNET_CRYPTO_cmp_peer_identity (other, &(s_elem->peer_id)))
   {
@@ -155,9 +175,11 @@
   }
   s_elem->is_empty = NOT_EMPTY;
 
+  #ifdef TO_FILE
   to_file (s_elem->file_name,
            "Now holding %s",
            GNUNET_i2s_full (&s_elem->peer_id));
+  #endif /* TO_FILE */
 }
 
 /**

Modified: gnunet/src/rps/gnunet-service-rps_sampler_elem.h
===================================================================
--- gnunet/src/rps/gnunet-service-rps_sampler_elem.h    2016-09-06 14:05:40 UTC 
(rev 37895)
+++ gnunet/src/rps/gnunet-service-rps_sampler_elem.h    2016-09-06 14:05:44 UTC 
(rev 37896)
@@ -120,6 +120,15 @@
 
 
 /**
+ * Destroy a sampler element.
+ *
+ * @param sampler_elem the element to destroy
+ */
+void
+RPS_sampler_elem_destroy (struct RPS_SamplerElement *sampler_elem);
+
+
+/**
  * Input an PeerID into the given sampler element.
  *
  * @param sampler the sampler the @a s_elem belongs to.

Modified: gnunet/src/rps/test_rps.c
===================================================================
--- gnunet/src/rps/test_rps.c   2016-09-06 14:05:40 UTC (rev 37895)
+++ gnunet/src/rps/test_rps.c   2016-09-06 14:05:44 UTC (rev 37896)
@@ -1292,6 +1292,7 @@
     {
       RPS_sampler_elem_next (s_elem, &rps_peer_ids[i]);
     }
+    RPS_sampler_elem_destroy (s_elem);
   }
   return GNUNET_OK;
 }




reply via email to

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