projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replace psets with arrays to make the compiler more predictable across runs (and...
[libfirm]
/
ir
/
obstack
/
obstack_printf.c
diff --git
a/ir/obstack/obstack_printf.c
b/ir/obstack/obstack_printf.c
index
ab494bb
..
eb5b86e
100644
(file)
--- a/
ir/obstack/obstack_printf.c
+++ b/
ir/obstack/obstack_printf.c
@@
-1,24
+1,24
@@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <assert.h>
#include "obstack.h"
#ifdef _WIN32
#define vsnprintf _vsnprintf
#endif
#include "obstack.h"
#ifdef _WIN32
#define vsnprintf _vsnprintf
#endif
-int obstack_
printf(struct obstack *obst, const char *fmt, ...
)
+int obstack_
vprintf(struct obstack *obst, const char *fmt, va_list ap
)
{
char buf[128];
char *buffer = buf;
{
char buf[128];
char *buffer = buf;
- size_t size = lengthof(buf);
- va_list ap;
+ size_t size = sizeof(buf);
int len;
for (;;) {
int len;
for (;;) {
- va_
start(ap, fmt)
;
-
len = vsnprintf(buffer, sizeof(buffer), fmt
, ap);
-
va_end(
ap);
+ va_
list tap
;
+
va_copy(tap
, ap);
+
len = vsnprintf(buffer, size, fmt, t
ap);
/* snprintf should return -1 only in the error case, but older glibcs
* and probably other systems are buggy in this respect and return -1 if
/* snprintf should return -1 only in the error case, but older glibcs
* and probably other systems are buggy in this respect and return -1 if
@@
-37,7
+37,7
@@
int obstack_printf(struct obstack *obst, const char *fmt, ...)
} else {
break;
}
} else {
break;
}
- buffer = malloc(
buffer,
size);
+ buffer = malloc(size);
}
obstack_grow(obst, buffer, len);
}
obstack_grow(obst, buffer, len);
@@
-46,3
+46,15
@@
int obstack_printf(struct obstack *obst, const char *fmt, ...)
return len;
}
return len;
}
+
+int obstack_printf(struct obstack *obst, const char *fmt, ...)
+{
+ va_list ap;
+ int res;
+
+ va_start(ap, fmt);
+ res = obstack_vprintf(obst, fmt, ap);
+ va_end(ap);
+
+ return res;
+}