aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-08 00:23:43 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-08 00:23:43 +0000
commit090375c0e8345803c7c666f623e376ed36173452 (patch)
tree0246589e41efabe7c7ab36f57515ee20721edffa /src
parent4d8d62298e1926c6f8bd26ad5a34b966ffeb188c (diff)
downloadgnunet-090375c0e8345803c7c666f623e376ed36173452.tar.gz
gnunet-090375c0e8345803c7c666f623e376ed36173452.zip
-fix leaks
Diffstat (limited to 'src')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_alice.c8
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_bob.c27
-rw-r--r--src/scalarproduct/test_scalarproduct.conf4
3 files changed, 31 insertions, 8 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
index f34da64f9..42041dabf 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
@@ -224,9 +224,9 @@ static struct GNUNET_CADET_Handle *my_cadet;
224 * @return #GNUNET_OK (continue to iterate) 224 * @return #GNUNET_OK (continue to iterate)
225 */ 225 */
226static int 226static int
227free_element (void *cls, 227free_element_cb (void *cls,
228 const struct GNUNET_HashCode *key, 228 const struct GNUNET_HashCode *key,
229 void *value) 229 void *value)
230{ 230{
231 struct GNUNET_SCALARPRODUCT_Element *e = value; 231 struct GNUNET_SCALARPRODUCT_Element *e = value;
232 232
@@ -273,7 +273,7 @@ destroy_service_session (struct AliceServiceSession *s)
273 if (NULL != s->intersected_elements) 273 if (NULL != s->intersected_elements)
274 { 274 {
275 GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements, 275 GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
276 &free_element, 276 &free_element_cb,
277 s); 277 s);
278 GNUNET_CONTAINER_multihashmap_destroy (s->intersected_elements); 278 GNUNET_CONTAINER_multihashmap_destroy (s->intersected_elements);
279 s->intersected_elements = NULL; 279 s->intersected_elements = NULL;
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c
index 38fc65f37..29e2d7eed 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct_bob.c
@@ -308,6 +308,25 @@ find_matching_cadet_session (const struct GNUNET_HashCode *key)
308 308
309 309
310/** 310/**
311 * Callback used to free the elements in the map.
312 *
313 * @param cls NULL
314 * @param key key of the element
315 * @param value the value to free
316 */
317static int
318free_element_cb (void *cls,
319 const struct GNUNET_HashCode *key,
320 void *value)
321{
322 struct GNUNET_SCALARPRODUCT_Element *element = value;
323
324 GNUNET_free (element);
325 return GNUNET_OK;
326}
327
328
329/**
311 * Destroy session state, we are done with it. 330 * Destroy session state, we are done with it.
312 * 331 *
313 * @param session the session to free elements from 332 * @param session the session to free elements from
@@ -351,7 +370,9 @@ destroy_service_session (struct BobServiceSession *s)
351 s)); 370 s));
352 if (NULL != s->intersected_elements) 371 if (NULL != s->intersected_elements)
353 { 372 {
354 /* FIXME: free elements */ 373 GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
374 &free_element_cb,
375 NULL);
355 GNUNET_CONTAINER_multihashmap_destroy (s->intersected_elements); 376 GNUNET_CONTAINER_multihashmap_destroy (s->intersected_elements);
356 s->intersected_elements = NULL; 377 s->intersected_elements = NULL;
357 } 378 }
@@ -758,6 +779,7 @@ compute_service_response (struct BobServiceSession *session)
758 &a[q[i]], 779 &a[q[i]],
759 &r_prime[i])); 780 &r_prime[i]));
760 } 781 }
782 gcry_mpi_release (tmp);
761 783
762 // Calculate S' = E(SUM( r_i^2 )) 784 // Calculate S' = E(SUM( r_i^2 ))
763 tmp = compute_square_sum (rand, count); 785 tmp = compute_square_sum (rand, count);
@@ -765,6 +787,7 @@ compute_service_response (struct BobServiceSession *session)
765 tmp, 787 tmp,
766 1, 788 1,
767 &session->s_prime); 789 &session->s_prime);
790 gcry_mpi_release (tmp);
768 791
769 // Calculate S = E(SUM( (r_i + b_i)^2 )) 792 // Calculate S = E(SUM( (r_i + b_i)^2 ))
770 for (i = 0; i < count; i++) 793 for (i = 0; i < count; i++)
@@ -774,6 +797,7 @@ compute_service_response (struct BobServiceSession *session)
774 tmp, 797 tmp,
775 1, 798 1,
776 &session->s); 799 &session->s);
800 gcry_mpi_release (tmp);
777 801
778 session->r = r; 802 session->r = r;
779 session->r_prime = r_prime; 803 session->r_prime = r_prime;
@@ -781,7 +805,6 @@ compute_service_response (struct BobServiceSession *session)
781 // release rand, b and a 805 // release rand, b and a
782 for (i = 0; i < count; i++) 806 for (i = 0; i < count; i++)
783 gcry_mpi_release (rand[i]); 807 gcry_mpi_release (rand[i]);
784 gcry_mpi_release (tmp);
785 GNUNET_free (session->e_a); 808 GNUNET_free (session->e_a);
786 session->e_a = NULL; 809 session->e_a = NULL;
787 GNUNET_free (p); 810 GNUNET_free (p);
diff --git a/src/scalarproduct/test_scalarproduct.conf b/src/scalarproduct/test_scalarproduct.conf
index 96a487a57..3cbfa95fe 100644
--- a/src/scalarproduct/test_scalarproduct.conf
+++ b/src/scalarproduct/test_scalarproduct.conf
@@ -12,7 +12,7 @@ OVERLAY_TOPOLOGY = CLIQUE
12WORKBITS=0 12WORKBITS=0
13 13
14[scalarproduct-bob] 14[scalarproduct-bob]
15#PREFIX = valgrind 15PREFIX = valgrind --leak-check=yes
16 16
17[scalarproduct-alice] 17[scalarproduct-alice]
18#PREFIX = valgrind \ No newline at end of file 18PREFIX = valgrind --leak-check=yes