1
2
3
4
5
6
7
8
9
10
11
12
13
14#include "qemu/osdep.h"
15#include <glib/gprintf.h>
16#include <dirent.h>
17#include <utime.h>
18
19#include "9p-marshal.h"
20
21P9ARRAY_DEFINE_TYPE(V9fsString, v9fs_string_free);
22
23void v9fs_string_free(V9fsString *str)
24{
25 g_free(str->data);
26 str->data = NULL;
27 str->size = 0;
28}
29
30void GCC_FMT_ATTR(2, 3)
31v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
32{
33 va_list ap;
34
35 v9fs_string_free(str);
36
37 va_start(ap, fmt);
38 str->size = g_vasprintf(&str->data, fmt, ap);
39 va_end(ap);
40}
41
42void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs)
43{
44 v9fs_string_free(lhs);
45 v9fs_string_sprintf(lhs, "%s", rhs->data);
46}
47