Home » Developing U++ » U++ Developers corner » C strings
Re: C strings [message #5714 is a reply to message #5712] |
Wed, 11 October 2006 04:26  |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
Quote: |
(or when it is negligible performance wise).
|
Quote: |
Not in all cases. For example,
void CodeEditor::Enclose(const char *c1, const char *c2)
{
int l, h;
if(!GetSelection(l, h))
return;
Insert(l, WString(c1));
Insert(h + strlen(c1), WString(c2));
ClearSelection();
SetCursor(h + strlen(c1) + strlen(c2));
}
Calculating the size of const string is already overhead.
|
You are not seeing the whole story. Enclose is always called with const char * literal parameters (of short lentgth). So makeing parameters String would enlarge the code size, as strlen has to be done anyway and you would just have to call String constructor twice and before each Enclose call.
Quote: |
For non-const strings, determination of the end of string by zero terminator is unsafe, because it may be lost, and work with this string can make security hole.
|
I do not think this is true. How could that be lost?
The fixed buffers for strings are security reasons, not trailing '\0' sentinels.
Quote: |
I know and understand, that removing C-like strings is huge work (and code works without it, really? ), but IMHO, if you attempted on STL, you can make library safer and faster.
|
Actually, that would be nice, but is a bit problematic because of nature of C++ string literals and because of external environment. (C++ string literals being the major problem).
|
|
|
Goto Forum:
Current Time: Fri Jun 06 21:23:50 CEST 2025
Total time taken to generate the page: 0.04597 seconds
|