mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
New function: dstring_strdup
I got tired of always doing dstring_newstr/dstring_copy, so I thought it was time to wrap it. dstring_strdup is the dstring equivalent of strdup.
This commit is contained in:
parent
fcdd046333
commit
baede61f4f
2 changed files with 15 additions and 2 deletions
|
@ -111,6 +111,11 @@ char *dstring_freeze (dstring_t *dstr);
|
|||
dstring_t *_dstring_newstr (dstring_mem_t *mem);
|
||||
dstring_t *dstring_newstr (void);
|
||||
//@}
|
||||
/** Create a new dstring from a string. Similar to strdup().
|
||||
\param str the string to copy
|
||||
\return inititialized dstring
|
||||
*/
|
||||
dstring_t *dstring_strdup (const char *str);
|
||||
/** Open up a hole in the string buffer. The contents of the opened hole
|
||||
are undefined. The size of the opened hole will be 1 bigger than specified
|
||||
allowing for a null terminator.
|
||||
|
|
|
@ -217,6 +217,14 @@ dstring_newstr (void)
|
|||
return _dstring_newstr (&dstring_default_mem);
|
||||
}
|
||||
|
||||
VISIBLE dstring_t *
|
||||
dstring_strdup (const char *str)
|
||||
{
|
||||
dstring_t *dstr = dstring_new ();
|
||||
dstring_copystr (dstr, str);
|
||||
return dstr;
|
||||
}
|
||||
|
||||
VISIBLE char *
|
||||
dstring_reservestr (dstring_t *dstr, unsigned len)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue