2 * This file is part of libFirm.
3 * Copyright (C) 2012 Karlsruhe Institute of Technology.
13 /* win32/C89 has no va_copy function... so we have to use the stupid fixed-length version */
14 int obstack_vprintf(struct obstack *obst, const char *fmt, va_list ap) FIRM_NOTHROW
17 int len = _vsnprintf(buf, sizeof(buf), fmt, ap);
18 obstack_grow(obst, buf, len);
22 int obstack_vprintf(struct obstack *obst, const char *fmt, va_list ap) FIRM_NOTHROW
26 size_t size = sizeof(buf);
32 len = vsnprintf(buffer, size, fmt, tap);
34 /* snprintf should return -1 only in the error case, but older glibcs
35 * and probably other systems are buggy in this respect and return -1 if
36 * the buffer was too small. We only abort for LARGE unrealistic buffer
44 } else if ((size_t)len >= size) {
45 /* If we come here more than once, vsnprintf() returned garbage */
46 assert(buffer == buf);
47 size = (size_t)len + 1;
51 buffer = (char*)malloc(size);
54 obstack_grow(obst, buffer, len);
62 int obstack_printf(struct obstack *obst, const char *fmt, ...) FIRM_NOTHROW
68 res = obstack_vprintf(obst, fmt, ap);