From cf6ccdf5e0b56a73ba35f792ec7f2fc2f852cbc1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 14 Apr 2018 11:45:17 +0200 Subject: [PATCH] There is no reason to allocate space for a constant string. Remove this. Signed-off-by: DL6ER --- api.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/api.c b/api.c index daf8fd18..81afce06 100644 --- a/api.c +++ b/api.c @@ -426,7 +426,7 @@ void getTopClients(char *client_message, int *sock) void getForwardDestinations(char *client_message, int *sock) { - bool allocated = false, sort = true; + bool sort = true; int i, temparray[counters.forwarded+1][2], forwardedsum = 0, totalqueries = 0; if(command(client_message, "unsorted")) @@ -473,14 +473,12 @@ void getForwardDestinations(char *client_message, int *sock) // Is this the "local" forward destination? if(j == counters.forwarded) { - ip = strdup("local"); + ip = "local"; name = ip; if(totalqueries > 0) // Whats the percentage of (cached + blocked) queries on the total amount of queries? percentage = 1e2f * (counters.cached + counters.blocked) / totalqueries; - - allocated = true; } else { @@ -511,8 +509,6 @@ void getForwardDestinations(char *client_message, int *sock) // we simply have to scale b by a which is what we do in the following. if(forwardedsum > 0 && totalqueries > 0) percentage = 1e2f * forwarded[j].count / forwardedsum * counters.forwardedqueries / totalqueries; - - allocated = false; } // Send data if count > 0 @@ -528,13 +524,6 @@ void getForwardDestinations(char *client_message, int *sock) pack_float(*sock, (float) percentage); } } - - // Free previously allocated memory only if we allocated it - if(allocated) - { - free(ip); - //free(name); // This is just the same as ip - } } if(debugclients)