Strdup

From Valve Developer Community
Revision as of 19:29, 13 January 2006 by Ts2do (talk | contribs)
Jump to navigation Jump to search

Defined as static functions in src\vgui2\controls\BitmapImagePanel.cpp and as CopyString in src\dlls\AI_ResponseSystem.cpp, this function simply returns a pointer to a clone of the string parameter. This function handles the repetative code that is seen when copying a string and makes it an inline function. If copied to src\game_shared\util_shared.h, this function could come in handy at times.

inline char *CloneString( const char *str )
{
	char *cloneStr = new char [ strlen(str)+1 ];
	strcpy( cloneStr, str );
	return cloneStr;
}