From 194fa45e0f191ab5c44afe7c55472f571d69d831 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 19 Dec 2011 23:01:03 +0000 Subject: [PATCH] -properly use DLL apis where appropriate --- src/statistics/statistics_api.c | 36 ++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index c30279e71..2838b7060 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -856,7 +856,6 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) { struct GNUNET_STATISTICS_GetHandle *pos; struct GNUNET_STATISTICS_GetHandle *next; - struct GNUNET_STATISTICS_GetHandle *prev; struct GNUNET_TIME_Relative timeout; int i; @@ -879,36 +878,23 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) h->current = NULL; } } - pos = h->action_head; - prev = NULL; - while (pos != NULL) + next = h->action_head; + while (NULL != (pos = next)) { next = pos->next; if (pos->type == ACTION_GET) { - if (prev == NULL) - h->action_head = next; - else - prev->next = next; + GNUNET_CONTAINER_DLL_remove (h->action_head, + h->action_tail, + pos); free_action_item (pos); } - else - { - prev = pos; - } - pos = next; - } - h->action_tail = prev; - if (h->current == NULL) - { - h->current = h->action_head; - if (h->action_head != NULL) - { - h->action_head = h->action_head->next; - if (h->action_head == NULL) - h->action_tail = NULL; - } } + if ( (NULL == h->current) && + (NULL != (h->current = h->action_head)) ) + GNUNET_CONTAINER_DLL_remove (h->action_head, + h->action_tail, + h->current); h->do_destroy = GNUNET_YES; if ((h->current != NULL) && (h->th == NULL)) { @@ -928,7 +914,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) } } if (h->th != NULL) - return; + return; /* do not finish destruction just yet */ } while (NULL != (pos = h->action_head)) { -- 2.25.1