[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9852 - GNUnet/src/applications/dv/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9852 - GNUnet/src/applications/dv/module |
Date: |
Mon, 21 Dec 2009 20:49:08 +0100 |
Author: nevans
Date: 2009-12-21 20:49:08 +0100 (Mon, 21 Dec 2009)
New Revision: 9852
Modified:
GNUnet/src/applications/dv/module/dv.c
Log:
partial memory leak fix, still 40 bytes that I can't find
Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c 2009-12-21 15:58:21 UTC (rev
9851)
+++ GNUnet/src/applications/dv/module/dv.c 2009-12-21 19:49:08 UTC (rev
9852)
@@ -108,6 +108,17 @@
}
#endif
+
+static int
+free_neighbor (const GNUNET_HashCode * key, void *value, void *cls)
+{
+ struct GNUNET_dv_neighbor * neighbor = (struct GNUNET_dv_neighbor *)value;
+ GNUNET_free (neighbor->neighbor);
+ GNUNET_free_non_null(neighbor->referrer);
+ GNUNET_free (neighbor);
+ return GNUNET_YES;
+}
+
/*
* Update the statistics about dv routing
*/
@@ -977,6 +988,7 @@
neighbor->neighbor_id =
GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, RAND_MAX - 1) + 1;
memcpy (neighbor->neighbor, peer, sizeof (GNUNET_PeerIdentity));
+ neighbor->referrer = NULL;
GNUNET_multi_hash_map_put (ctx->direct_neighbors, &peer->hashPubKey,
neighbor, GNUNET_MultiHashMapOption_REPLACE);
}
@@ -1029,8 +1041,8 @@
#endif
if ( ( (neighbor->referrer == NULL) &&
- (0 == memcmp (neighbor->neighbor,
- toMatch,
+ (0 == memcmp (neighbor->neighbor,
+ toMatch,
sizeof (GNUNET_PeerIdentity))) ) ||
( (neighbor->referrer != NULL) &&
(0 == memcmp (neighbor->referrer, toMatch,
@@ -1088,8 +1100,11 @@
&peer->hashPubKey);
GNUNET_CONTAINER_heap_iterate (ctx->neighbor_max_heap,
&delete_callback, (void *) peer);
- /* delete_callback will free 'neighbour' (and members) */
+ /* delete_callback will free 'neighbor' (and members) */
}
+ GNUNET_free(neighbor->neighbor);
+ GNUNET_free_non_null(neighbor->referrer);
+ GNUNET_free(neighbor);
}
GNUNET_mutex_unlock (ctx->dvMutex);
#if DEBUG_DV
@@ -1405,7 +1420,9 @@
coreAPI->peer_disconnect_notification_unregister (&peer_connect_handler,
NULL);
GNUNET_cron_del_job (coreAPI->cron, &maintain_dv_job,
- GNUNET_DV_MAINTAIN_FREQUENCY, NULL);
+ GNUNET_DV_MAINTAIN_FREQUENCY, NULL);
+ GNUNET_multi_hash_map_iterate (ctx->direct_neighbors, &free_neighbor, NULL);
+ GNUNET_multi_hash_map_iterate (ctx->extended_neighbors, &free_neighbor,
NULL);
GNUNET_multi_hash_map_destroy (ctx->direct_neighbors);
GNUNET_multi_hash_map_destroy (ctx->extended_neighbors);
GNUNET_CONTAINER_heap_destroy (ctx->neighbor_max_heap);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9852 - GNUnet/src/applications/dv/module,
gnunet <=