On Tue, Oct 16, 2001, Henrik Nordstrom wrote:
> Adrian Chadd wrote:
>
> > Ok, so here's my question: in access_log.c, there's this bit of code:
> >
> > buf = xcalloc((strlen(header) * 3) + 1, 1);
> >
> > Now, it _looks_ like someone got the xcalloc arguments backwards,
> > right? Can anyone see any reason why this code should be allocating
> > RAM using the above arguments?
>
> Does not really matter.
>
> xcalloc((strlen(header) * 3) + 1, 1)
>
> allocate an array of 1 byte items (char), (strlen(header) * 3) + 1 long
>
> xcalloc(1, (strlen(header) * 3) + 1)
>
> allocate one item, (strlen(header) * 3) + 1 long
Oh, I gather that the end result is the same, since calloc is just
allocing an array of the given size. I just thought it may be a bit
weird (and it generates type warnings too :-)
Would you mind if for the sake of conformity I reverted the arguments?
Adrian
Received on Tue Oct 16 2001 - 18:48:07 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:33 MST