httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregory Nicholls <gnicho...@level8.com>
Subject Re: apr_send using const char instead of void ??
Date Wed, 20 Sep 2000 12:56:07 GMT
  True, but doesn't this only prove beneficial if all data is null
terminated ?? I mean wouldn't the following style work as well ?? This puts
the onus on the callee to cast the pointer if he needs to . . .

int func(void *pv)
 {
  char *p, *q;
  q=(char *)pv;
  p=strchr(q, '?' );
  return(p-q);
 }

    G.



"William A. Rowe, Jr." wrote:

> > From: Gregory Nicholls [mailto:gnicholls@level8.com]
> > Sent: Wednesday, September 20, 2000 7:29 AM
> >
> >  By length calculations are you referring to sizeof() ??
> >     G.
>
> I doubt it... he's discussing pointer arithmetic (if I'm clear):
>
> void *p, *q;
> p = strchr (q, '?');
> return p - q;
>
> ... is an invalid construct, since the 'size' of p and q are
> undefined.
>
> > Tony Finch wrote:
> >
> > > Jeff Trawick <trawickj@bellsouth.net> wrote:
> > > >Gregory Nicholls <gnicholls@level8.com> writes:
> > > >
> > > >>     Question: The prototype for function apr_send uses a
> > const char * as it's
> > > >> buffer parm type. Is there a reason that this isn't a
> > void * ??? I mean I know I
> > > >> can cast it but I'm wondering if there's something I
> > don't understand.
> > > >
> > > >"const void *" sounds better to me, too.
> > >
> > > A reason in favour of char* is that length calculations on void
> > > pointers are forbidden. If the latter were not true I'd be in favour
> > > of void* too, but then void* would effectively be no different from
> > > char*.
>
> I'd also point out that everything we are sending up or down is
> octet data, so char* is entirely appropriate.  Even utf-7/utf-8
> are octet streams.


Mime
View raw message