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,13 +48,14 @@ void dstring_snip (dstring_t *dstr, unsigned int pos, unsigned int len);
|
||||||
void dstring_clear (dstring_t *dstr);
|
void dstring_clear (dstring_t *dstr);
|
||||||
void dstring_replace (dstring_t *dstr, unsigned int pos, unsigned int rlen,
|
void dstring_replace (dstring_t *dstr, unsigned int pos, unsigned int rlen,
|
||||||
const char *data, unsigned int len);
|
const char *data, unsigned int len);
|
||||||
|
char *dstring_freeze (dstring_t *dstr);
|
||||||
|
|
||||||
// String-specific functions
|
// String-specific functions
|
||||||
dstring_t *dstring_newstr (void);
|
dstring_t *dstring_newstr (void);
|
||||||
void dstring_appendstr (dstring_t *dstr, const char *str);
|
void dstring_appendstr (dstring_t *dstr, const char *str);
|
||||||
void dstring_appendsubstr (dstring_t *dstr, const char *str, unsigned int len);
|
void dstring_appendsubstr (dstring_t *dstr, const char *str, unsigned int len);
|
||||||
void dstring_insertstr (dstring_t *dstr, unsigned int pos, const char *str);
|
void dstring_insertstr (dstring_t *dstr, unsigned int pos, const char *str);
|
||||||
void dstring_insertsubstr (dstring_t *dstr, unsigned int pos, const char *str,
|
void dstring_insertsubstr (dstring_t *dstr, unsigned int pos, const char *str,
|
||||||
unsigned int len);
|
unsigned int len);
|
||||||
void dstring_clearstr (dstring_t *dstr);
|
void dstring_clearstr (dstring_t *dstr);
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,14 @@ dstring_replace (dstring_t *dstr, unsigned int pos, unsigned int rlen,
|
||||||
memcpy (dstr->str + pos, data, len);
|
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_t *
|
||||||
dstring_newstr (void)
|
dstring_newstr (void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue