httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Pane <bri...@apache.org>
Subject Re: Cleanup in 'server/mpm/fdqueue.c'
Date Sat, 26 Nov 2005 04:18:51 GMT
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.

But in the case of this particular code, which only gets called
once, we really don't need the optimization.

Brian


Mime
View raw message