Skip to content

Commit

Permalink
Added an AutoStr constructor from C string
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 13, 2012
1 parent efdbd30 commit f11a087
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doomsday/engine/api/dd_string.h
Expand Up @@ -378,6 +378,16 @@ AutoStr* AutoStr_NewStd(void);
*/
AutoStr* AutoStr_FromStr(ddstring_t* str);

/**
* Constructs an AutoStr instance (zone allocated) and initializes its
* contents with @a text.
*
* @param text Text for the new string.
*
* @return AutoStr instance.
*/
AutoStr* AutoStr_FromText(const char* text);

/**
* Converts an AutoStr to a normal ddstring. You must call Str_Delete()
* on the returned string manually to destroy it.
Expand Down
5 changes: 5 additions & 0 deletions doomsday/engine/portable/src/m_string.c
Expand Up @@ -856,6 +856,11 @@ AutoStr* AutoStr_FromStr(ddstring_t* str)
return str;
}

AutoStr* AutoStr_FromText(const char* text)
{
return Str_Set(AutoStr_New(), text);
}

ddstring_t* Str_FromAutoStr(AutoStr* as)
{
Garbage_Untrash(as);
Expand Down

0 comments on commit f11a087

Please sign in to comment.