[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String functions with end pointers?
From: |
Stepan Kasal |
Subject: |
Re: String functions with end pointers? |
Date: |
Mon, 22 May 2006 19:36:00 +0200 |
User-agent: |
Mutt/1.4.2.1i |
Hello,
On Fri, May 05, 2006 at 11:10:48PM -0600, Bob Proulx wrote:
> Paul D. Smith wrote:
> > I'd much prefer to keep a pointer to the end of the buffer: this won't
> > change so it doesn't need to be managed. For example, something like:
> >
> > char *strpchr(const char *str, const char *endp, int c);
> >
> > or whatever.
> >
> > Of course, there aren't any standard str*() or mem*() functions that I'm
> > aware of that use an end pointer instead of a length.
>
> I read this and could not help but notice the similarity to the C++
> STL iterators. However the STL always uses a pointer to one beyond
> the end of the data while the above (if I read that correctly) uses a
> pointer within the bounds. I am not saying one is better than the
> other. Just noting the similarity and the difference.
when I read the articles in this thread, I always supposed that endp
is pointing beyond the data, i.e. that (endp - str) is the size.
I think it would be confusing to do it otherwise.
Have a nice day,
Stepan