mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 12:52:46 +00:00
Added the useful dstring_freeze function to convert a dstring to a
finalized, plain C string.
This commit is contained in:
parent
23278d0706
commit
63c3038ad8
2 changed files with 11 additions and 2 deletions
|
@ -48,6 +48,7 @@ void dstring_snip (dstring_t *dstr, unsigned int pos, unsigned int len);
|
|||
void dstring_clear (dstring_t *dstr);
|
||||
void dstring_replace (dstring_t *dstr, unsigned int pos, unsigned int rlen,
|
||||
const char *data, unsigned int len);
|
||||
char *dstring_freeze (dstring_t *dstr);
|
||||
|
||||
// String-specific functions
|
||||
dstring_t *dstring_newstr (void);
|
||||
|
|
|
@ -126,6 +126,14 @@ dstring_replace (dstring_t *dstr, unsigned int pos, unsigned int rlen,
|
|||
memcpy (dstr->str + pos, data, len);
|
||||
}
|
||||
|
||||
char *
|
||||
dstring_freeze (dstring_t *dstr)
|
||||
{
|
||||
char *str = realloc (dstr->str, dstr->size);
|
||||
free (dstr);
|
||||
return str;
|
||||
}
|
||||
|
||||
dstring_t *
|
||||
dstring_newstr (void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue