]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
From Andres Kroonmaa:
authorhno <>
Tue, 10 Apr 2001 23:01:35 +0000 (23:01 +0000)
committerhno <>
Tue, 10 Apr 2001 23:01:35 +0000 (23:01 +0000)
avoid needless malloc/free of 2 byte string

src/access_log.cc

index e30cc9f556e0f2528fe846fb1e114c399cf98e27..e007002b608bbc3e5ed4cc149e9d2d9ed0d92f9a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: access_log.cc,v 1.67 2001/02/07 18:56:51 hno Exp $
+ * $Id: access_log.cc,v 1.68 2001/04/10 17:01:35 hno Exp $
  *
  * DEBUG: section 46    Access Log
  * AUTHOR: Duane Wessels
@@ -227,7 +227,7 @@ static char *
 accessLogFormatName(const char *name)
 {
     if (NULL == name)
-       return xcalloc(strlen(dash_str) + 1, 1);
+       return NULL;
     return username_quote(name);
 }
 
@@ -240,6 +240,8 @@ accessLogSquid(AccessLogEntry * al)
        client = fqdncache_gethostbyaddr(al->cache.caddr, FQDN_LOOKUP_IF_MISS);
     if (client == NULL)
        client = inet_ntoa(al->cache.caddr);
+    user = accessLogFormatName(al->cache.authuser ?
+       al->cache.authuser : al->cache.rfc931);
     logfilePrintf(logfile, "%9d.%03d %6d %s %s/%03d %d %s %s %s %s%s/%s %s",
        (int) current_time.tv_sec,
        (int) current_time.tv_usec / 1000,
@@ -250,8 +252,7 @@ accessLogSquid(AccessLogEntry * al)
        al->cache.size,
        al->private.method_str,
        al->url,
-       (user = accessLogFormatName(al->cache.authuser ?
-               al->cache.authuser : al->cache.rfc931)),
+       user ? user : dash_str,
        al->hier.ping.timedout ? "TIMEOUT_" : "",
        hier_strings[al->hier.code],
        al->hier.host,
@@ -268,10 +269,11 @@ accessLogCommon(AccessLogEntry * al)
        client = fqdncache_gethostbyaddr(al->cache.caddr, 0);
     if (client == NULL)
        client = inet_ntoa(al->cache.caddr);
+    user = accessLogFormatName(al->cache.authuser);
     logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %d %s:%s",
        client,
        accessLogFormatName(al->cache.rfc931),
-       (user = accessLogFormatName(al->cache.authuser)),
+       user ? user : dash_str,
        mkhttpdlogtime(&squid_curtime),
        al->private.method_str,
        al->url,