On Tue, 12 Jul 2011 10:59:58 -0400, Steven Schveighoffer
<schvei...@yahoo.com> wrote:
On Tue, 12 Jul 2011 10:50:07 -0400, Regan Heath <re...@netmail.co.nz>
wrote:
and in both cases, toStringz would do nothing as foo is zero terminated
already (in both cases), or am I wrong about that?
In neither case are they required to be null terminated. The only thing
that guarantees null termination is a string literal. Even "abc".dup is
not going to be guaranteed to be null terminated. For an actual
example, try "012345678901234".dup. This should have a 0x0f right after
the last character.
And, actually, the cost penalty of checking if you are going to segfault
(i.e. checking if the ptr is into heap data, and then getting the length)
is quite costly. You must take the GC lock.
-Steve