obprintf.c 596 B

1234567891011121314151617181920212223242526272829
  1. /* Copyright (C) 2013 Gentoo Foundation
  2. * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  3. */
  4. #include <stdio.h>
  5. #include <stdarg.h>
  6. #include <obstack.h>
  7. int
  8. obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
  9. {
  10. int n;
  11. char *s;
  12. n = vasprintf(&s, format, args);
  13. obstack_grow(obstack, s, n);
  14. return n;
  15. }
  16. libc_hidden_def(obstack_vprintf)
  17. int
  18. obstack_printf (struct obstack *obstack, const char *format, ...)
  19. {
  20. int n;
  21. va_list ap;
  22. va_start (ap, format);
  23. n = obstack_vprintf (obstack, format, ap);
  24. va_end (ap);
  25. return n;
  26. }