Re: needless xcalloc(sz=2) in access_log.c

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Tue, 10 Apr 2001 19:07:20 +0200

Nevermind.

The error was more in how the patches was attached to your message than
the format of them. You forwarded the unified diffs, but any whitespace
in the diffs was trashed by your mailer making me totally confused.

/ Henrik

Henrik Nordstrom wrote:
>
> Can you please post a unified diff (-u option)?
>
> To avoid having to specify -u all the time you can add the following to
> your .cvsrc file:
>
> diff -u -w
>
> Makes "cvs diff" produce unified diffs, ignoring any changes in
> whitespace only.
>
> /Henrik
>
> Andres Kroonmaa wrote:
> >
> > While trying to find who the hell mallocs sizes of <4 bytes at a rate
> > of 30-60/sec, and found problem with xmalloc_stats in util.c, I also
> > found that access_log.c calls needless xcalloc for "-" when username
> > is NULL.
> >
> > pls consider for HEAD.
> >
> > ------- Forwarded message follows -------
> >
> > Modified Files:
> > Tag: akroonmaa-head
> > access_log.c
> > Log Message:
> > avoid needless malloc/free of 2 byte string
> >
> > Index: access_log.c
> > ===================================================================
> > RCS file: /cvsroot/squid/squid/src/access_log.c,v
> > retrieving revision 1.10
> > retrieving revision 1.10.24.1
> > diff -w -u -r1.10 -r1.10.24.1
> > --- access_log.c 2001/02/07 19:11:47 1.10
> > +++ access_log.c 2001/04/10 11:59:31 1.10.24.1
> > @@ -227,7 +227,7 @@
> > accessLogFormatName(const char *name)
> > {
> > if (NULL == name)
> > - return xcalloc(strlen(dash_str) + 1, 1);
> > + return NULL;
> > return username_quote(name);
> > }
> >
> > @@ -240,6 +240,8 @@
> > 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 @@
> > 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 @@
> > 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,
> >
> > ------------------------------------ Andres Kroonmaa CTO, Delfi Online
> > Tel: 6501 731, Fax: 6501 708 Pärnu mnt. 158, Tallinn, 11317 Estonia
Received on Tue Apr 10 2001 - 11:05:20 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:13:44 MST