qemu/fsdev/9p-marshal.c
<<
>>
Prefs
   1/*
   2 * 9p backend
   3 *
   4 * Copyright IBM, Corp. 2010
   5 *
   6 * Authors:
   7 *  Anthony Liguori   <aliguori@us.ibm.com>
   8 *
   9 * This work is licensed under the terms of the GNU GPL, version 2.  See
  10 * the COPYING file in the top-level directory.
  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
  21void v9fs_string_free(V9fsString *str)
  22{
  23    g_free(str->data);
  24    str->data = NULL;
  25    str->size = 0;
  26}
  27
  28void GCC_FMT_ATTR(2, 3)
  29v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
  30{
  31    va_list ap;
  32
  33    v9fs_string_free(str);
  34
  35    va_start(ap, fmt);
  36    str->size = g_vasprintf(&str->data, fmt, ap);
  37    va_end(ap);
  38}
  39
  40void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs)
  41{
  42    v9fs_string_free(lhs);
  43    v9fs_string_sprintf(lhs, "%s", rhs->data);
  44}
  45