Re: CString help
- From: "Mihai N." <nmihai_year_2000@xxxxxxxxx>
- Date: Tue, 26 Jun 2007 00:47:29 -0700
This is going 'round in circles. :) You've restated what I said at the
beginning:
It looks like it :-)
But maybe because I don't see the guarantee of contigous space
as enough to make that kind of code legal.
First, the fact remains that the technique writes into a buffer
that has no write access in any standard way.
Even if the buffer is required to be contigous by the standard,
one implementation can have other things that might matter.
Let's say I decide to keep the sting in the belly as Pascal string
(length + non-zero ending buffer), or that I calculate a hash
value on the string content.
Once I change the buffer in a non-suported way, the coherence
of the string object is not guaranteed anymore.
Adding in the standard requirments like continuity, or no COW,
increase the chances that implementations will be restricted
enough so that the trick described is safe.
But the really usefull and safe thing is to provide *in the standard*
a contractual way to write in the buffer: aquire write access,
write, release write access (the patern implemented by CString
with GetBuffer/ReleaseBuffer).
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
.
- Follow-Ups:
- Re: CString help
- From: Doug Harrison [MVP]
- Re: CString help
- References:
- Re: CString help
- From: jp2code
- Re: CString help
- From: David Wilkinson
- Re: CString help
- From: Mihai N.
- Re: CString help
- From: Doug Harrison [MVP]
- Re: CString help
- From: Mihai N.
- Re: CString help
- From: Doug Harrison [MVP]
- Re: CString help
- From: Mihai N.
- Re: CString help
- From: Doug Harrison [MVP]
- Re: CString help
- From: Mihai N.
- Re: CString help
- From: Doug Harrison [MVP]
- Re: CString help
- From: Mihai N.
- Re: CString help
- From: Doug Harrison [MVP]
- Re: CString help
- Prev by Date: Re: typical exception with new and delete
- Next by Date: Re: App Unicode call MBCS dll
- Previous by thread: Re: CString help
- Next by thread: Re: CString help
- Index(es):
Relevant Pages
|