2
0

qapi-type-helpers.c 852 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * QAPI common helper functions
  3. *
  4. * This file provides helper functions related to types defined
  5. * in the QAPI schema.
  6. *
  7. * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  8. * See the COPYING.LIB file in the top-level directory.
  9. *
  10. */
  11. #include "qemu/osdep.h"
  12. #include "qapi/error.h"
  13. #include "qapi/type-helpers.h"
  14. HumanReadableText *human_readable_text_from_str(GString *str)
  15. {
  16. HumanReadableText *ret = g_new0(HumanReadableText, 1);
  17. ret->human_readable_text = g_steal_pointer(&str->str);
  18. return ret;
  19. }
  20. char **strv_from_str_list(const strList *list)
  21. {
  22. const strList *tail;
  23. int i = 0;
  24. char **strv = g_new(char *, QAPI_LIST_LENGTH(list) + 1);
  25. for (tail = list; tail != NULL; tail = tail->next) {
  26. strv[i++] = g_strdup(tail->value);
  27. }
  28. strv[i] = NULL;
  29. return strv;
  30. }