Strdup: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
Defined as static | Defined as a static <code>CloneString</code> in <code>src\vgui2\controls\BitmapImagePanel.cpp</code> and as a static <code>CopyString</code> in <code>src\dlls\AI_ResponseSystem.cpp</code>, 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 <code>src\game_shared\util_shared.h</code>, this function could come in handy at times. | ||
inline char *CloneString( const char *str ) | inline char *CloneString( const char *str ) | ||
{ | { |
Revision as of 18:39, 12 May 2006
Defined as a static CloneString
in src\vgui2\controls\BitmapImagePanel.cpp
and as a static 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; }