httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: Cleanup in 'server/mpm/fdqueue.c'
Date Sat, 26 Nov 2005 10:08:23 GMT
On Fri, Nov 25, 2005 at 08:18:51PM -0800, Brian Pane wrote:
> On Nov 21, 2005, at 1:34 PM, Christophe Jaillet wrote:
> 
> >Around line 61 in function ap_queue_info_create, in 'server/mpm/ 
> >fdqueue.c'
> >
> >the following sequence can cleaned-up :
> >===============================
> >    qi = apr_palloc(pool, sizeof(*qi));
> >    memset(qi, 0, sizeof(*qi));
> >===============================
> >
> >by using a 'apr_pcalloc' :
> >===============================
> >    qi = apr_pcalloc(pool, sizeof(*qi));
> >===============================
> 
> I think the usual reason that the apr_palloc+memset pattern is
> used instead of apr_pcalloc in httpd and APR code is to allow
> the compiler generate inline code to fill the structure with zeros.
> gcc, for example, will apply this optimization if the struct is small.
> If the struct is large, gcc will generate a call to memset.  With an
> apr_palloc call, the compiler doesn't have enough information
> to apply the optimization.

apr_pcalloc has been a macro for quite a long time now :)

#define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size)

joe

Mime
View raw message