From e9193626202ed4b13586eaf0f422e0c9079fe9ce Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 26 Mar 2012 08:54:17 +0200 Subject: [PATCH] dnsproxy: Refactor request destroy code Move common code into a function for destroying the request data. --- src/dnsproxy.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/dnsproxy.c b/src/dnsproxy.c index 7c75dd8..4033f2a 100644 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -2650,6 +2650,17 @@ static int create_listener(struct listener_data *ifdata) return 0; } +static void destroy_request_data(struct request_data *req) +{ + if (req->timeout > 0) + g_source_remove(req->timeout); + + g_free(req->resp); + g_free(req->request); + g_free(req->name); + g_free(req); +} + static void destroy_listener(struct listener_data *ifdata) { GSList *list; @@ -2662,13 +2673,7 @@ static void destroy_listener(struct listener_data *ifdata) DBG("Dropping pending request (id 0x%04x -> 0x%04x)", req->srcid, req->dstid); - if (req->timeout > 0) - g_source_remove(req->timeout); - - g_free(req->resp); - g_free(req->request); - g_free(req->name); - g_free(req); + destroy_request_data(req); list->data = NULL; } @@ -2680,13 +2685,7 @@ static void destroy_listener(struct listener_data *ifdata) DBG("Dropping request (id 0x%04x -> 0x%04x)", req->srcid, req->dstid); - if (req->timeout > 0) - g_source_remove(req->timeout); - - g_free(req->resp); - g_free(req->request); - g_free(req->name); - g_free(req); + destroy_request_data(req); list->data = NULL; } -- 2.7.4