From 92bfdba1d7e2dcb716eb1fe3ac286e42301db33d Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 2 Feb 2008 01:01:04 +0100 Subject: [PATCH] src/sn_network.c: Fixed two memory leaks. --- src/sn_network.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sn_network.c b/src/sn_network.c index 3934e91..7aa1ae9 100644 --- a/src/sn_network.c +++ b/src/sn_network.c @@ -34,6 +34,7 @@ void sn_network_destroy (sn_network_t *n) sn_stage_destroy (n->stages[i]); n->stages[i] = NULL; } + free (n->stages); n->stages = NULL; } @@ -68,8 +69,11 @@ int sn_network_stage_remove (sn_network_t *n, int s_num) n->stages[s_num] = NULL; if (nmemb > 0) + { memmove (n->stages + s_num, n->stages + (s_num + 1), nmemb * sizeof (sn_stage_t *)); + n->stages[n->stages_num - 1] = NULL; + } n->stages_num--; /* Free the unused memory */ @@ -202,13 +206,13 @@ static int sn_network_add_bitonic_merger_recursive (sn_network_t *n, int m; int i; + if (num == 1) + return (0); + s = sn_stage_create (n->stages_num); if (s == NULL) return (-1); - if (num == 1) - return (0); - m = num / 2; for (i = low; i < (low + m); i++) -- 2.11.0