7 #define vsnprintf _vsnprintf
10 int obstack_printf(struct obstack *obst, const char *fmt, ...)
18 len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
20 if (len < 0 || len >= (int) sizeof(buffer)) {
21 size_t size = len >= 0 ? (size_t) len : sizeof(buffer) * 2;
22 char *buffer = malloc(size);
28 len = vsnprintf(buffer, size, fmt, ap);
31 /* snprintf should return -1 only in the error case, but older
32 * glibcs and probably other systems are buggy in this respect and
33 * return -1 if the buffer was too small. We only abort for LARGE
34 * unrealistic buffer sizes here */
39 buffer = realloc(buffer, size);
40 } else if (len >= (int) size) {
41 /* this should not happen if snprintf works correctly */
47 obstack_grow(obst, buffer, len);