aspell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [aspell-devel] The String class for 0.60 does not null terminatestri


From: Kevin Atkinson
Subject: Re: [aspell-devel] The String class for 0.60 does not null terminatestrings.
Date: Mon, 27 Sep 2004 16:54:00 -0600 (MDT)

On Mon, 27 Sep 2004, Gary Setter wrote:

> <snip>
> > I repeat:  The string is only null termined when the c_str() or
> > ensure_null_end() is called.
> >
> Look at your String class. You have several public methods that
> return begin_ without null termination.

So What.  If someone want a null terminated string use c_str() or first call 
ensure_null_end().  That is the way I designed it and that is the way 
Aspell uses it.

> No one I know maintains none null terminated lists this way. It
> is too easy to forget and have a problem. Null termination is not
> costly. You might make your code run faster by not appending
> characters one at a time to a string.

The std::string class (NOT the Microsoft string class) does NOT guarantee
that the string is always null terminated.  In fact it doesn't even
guarantee that the string will be stored in a continuous area of memory.  
The only thing it guarantees is that that the c_str() method will return a
pointer to a null terminated string.  The string returned is invalided when
any non-const member function is called.

The acommon::String class is modeled after the std::string class expect 
that it guarantees that the string will be stored is a continuous area of 
memory.

-- 
http://kevin.atkinson.dhs.org





reply via email to

[Prev in Thread] Current Thread [Next in Thread]