U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » U++ Developers corner » C strings
Re: C strings [message #5712 is a reply to message #5693] Tue, 10 October 2006 21:38 Go to previous messageGo to previous message
Shire is currently offline  Shire
Messages: 41
Registered: September 2006
Location: Russia, Yamal peninsula
Member
Quote:

char * is used in chances are that string itself will be supplied as constant or other char * (avoiding performance and code size loss of char * -> String conversion) AND there is no further string length testing (or when it is negligible performance wise).


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.
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 know and understand, that removing C-like strings is huge work (and code works without it, really? Wink ), but IMHO, if you attempted on STL, you can make library safer and faster.
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Current porting state?
Next Topic: What about LUA plugin?
Goto Forum:
  


Current Time: Tue Sep 15 05:23:49 GMT+2 2026

Total time taken to generate the page: 0.00978 seconds