mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
add dstring_copy and dstring_copystr to make dstring init easier
This commit is contained in:
parent
d68b4b6121
commit
be0b3867c7
2 changed files with 18 additions and 0 deletions
|
@ -41,6 +41,7 @@ typedef struct dstring_s {
|
|||
dstring_t *dstring_new(void);
|
||||
void dstring_delete (dstring_t *dstr);
|
||||
void dstring_adjust (dstring_t *dstr);
|
||||
void dstring_copy (dstring_t *dstr, const char *data, unsigned int len);
|
||||
void dstring_append (dstring_t *dstr, const char *data, unsigned int len);
|
||||
void dstring_insert (dstring_t *dstr, unsigned int pos, const char *data,
|
||||
unsigned int len);
|
||||
|
@ -52,6 +53,7 @@ char *dstring_freeze (dstring_t *dstr);
|
|||
|
||||
// String-specific functions
|
||||
dstring_t *dstring_newstr (void);
|
||||
void dstring_copystr (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_insertstr (dstring_t *dstr, unsigned int pos, const char *str);
|
||||
|
|
|
@ -70,6 +70,14 @@ dstring_adjust (dstring_t *dstr)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
dstring_copy (dstring_t *dstr, const char *data, unsigned int len)
|
||||
{
|
||||
dstr->size = len;
|
||||
dstring_adjust (dstr);
|
||||
memcpy (dstr->str, data, len);
|
||||
}
|
||||
|
||||
void
|
||||
dstring_append (dstring_t *dstr, const char *data, unsigned int len)
|
||||
{
|
||||
|
@ -149,6 +157,14 @@ dstring_newstr (void)
|
|||
return new;
|
||||
}
|
||||
|
||||
void
|
||||
dstring_copystr (dstring_t *dstr, const char *str)
|
||||
{
|
||||
dstr->size = strlen (str) + 1;
|
||||
dstring_adjust (dstr);
|
||||
strcpy (dstr->str, str);
|
||||
}
|
||||
|
||||
void
|
||||
dstring_appendstr (dstring_t *dstr, const char *str)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue