gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r14476 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r14476 - gnunet/src/vpn
Date: Mon, 21 Feb 2011 11:03:43 +0100

Author: toelke
Date: 2011-02-21 11:03:43 +0100 (Mon, 21 Feb 2011)
New Revision: 14476

Modified:
   gnunet/src/vpn/gnunet-daemon-exit.c
   gnunet/src/vpn/gnunet-daemon-vpn.c
Log:
Begone foul memory leaks!

Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2011-02-21 10:03:42 UTC (rev 14475)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2011-02-21 10:03:43 UTC (rev 14476)
@@ -125,12 +125,26 @@
 static struct GNUNET_CONTAINER_MultiHashMap *udp_services;
 
 /**
+ * Function that frees everything from a hashmap
+ */
+static int
+free_iterate(void* cls, const GNUNET_HashCode* hash, void* value)
+{
+  GNUNET_free(value);
+  return GNUNET_YES;
+}
+
+/**
  * Function scheduled as very last function, cleans up after us
  */
 static void
 cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
     GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
 
+    GNUNET_CONTAINER_multihashmap_iterate(udp_connections,
+                                          free_iterate,
+                                          NULL);
+
     if (mesh_handle != NULL)
       {
        GNUNET_MESH_disconnect(mesh_handle);
@@ -501,6 +515,8 @@
       GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, 
"exit", "IPV4MASK", &ipv4mask));
       inet_pton(AF_INET, ipv4addr, &tmp);
       inet_pton(AF_INET, ipv4mask, &tmp2);
+      GNUNET_free(ipv4addr);
+      GNUNET_free(ipv4mask);
 
       /* This should be a noop */
       tmp = tmp & tmp2;
@@ -586,6 +602,8 @@
       GNUNET_CONTAINER_multihashmap_contains (udp_connections, &hash))
     GNUNET_CONTAINER_multihashmap_put (udp_connections, &hash, state,
                                        
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+  else
+    GNUNET_free(state);
 
   (void)GNUNET_DISK_file_write(helper_handle->fh_to_helper, buf, len);
   return GNUNET_YES;

Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c  2011-02-21 10:03:42 UTC (rev 14475)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c  2011-02-21 10:03:43 UTC (rev 14476)
@@ -272,6 +272,7 @@
                                                           
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
          {
            GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not store to hashmap\n");
+            GNUNET_free(value);
          }
 
 




reply via email to

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