Re: CString
- From: "Jonathan Wood" <jwood@xxxxxxxxxxxxxxxx>
- Date: Wed, 22 Aug 2007 09:38:40 -0600
Well, for starters, the member variable used to track the string length is type int, so right there is a limit of around 2GB. In addition, depending on system variations, the largest single block of memory you're likely to be able to allocate is less than this. Further, since CString resizes generally allocate an entire new block of memory before freeing the current one, the largest string is probably significantly less than that.
So the actual limit varies. Certainly, you cannot make it infinitely long.
Personally, I don't find this approach very efficient. I would create my own class that allocates string memory using malloc(). I would use realloc() to grow the memory as this provides some chance that the block does not need to be moved. In addition, each time the memory is reallocated, I would increase the memory size by some fixed amount (say, 2048 chars). This way, the data would not need to be reallocated every single time data is added to the string.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"RAN" <nijenhuis@xxxxxxx> wrote in message news:1187792327.057092.10510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I want to know how much characters can be stored in a CString.
Does anyone know an official document where this is documented ?
I have a program that concatenates textstrings to a CString every 1ms,
after that the CString is via SetWindowText(CString) inserted into a
multiline CEdit control. After some time at least a 100.000 characters
are visible in the CEdit control. So every 1ms i do (CString) a +=
"blabla";
CEdit.SetWindowText(a); Apperently i can make the CString infinitely
long (!?) .
How does this work for CString ?
.
- References:
- CString
- From: RAN
- CString
- Prev by Date: Re: WM_LBUTTONDOWN in Multi-document interface
- Next by Date: Re: Drawing continuously(dynamically) in MFC .
- Previous by thread: Re: CString
- Next by thread: Re: CString
- Index(es):