preprocessor runs once

This commit is contained in:
Andrew Kelley
2015-08-05 21:47:08 -07:00
parent e71521335a
commit d519ce87dd
6 changed files with 99 additions and 32 deletions

View File

@@ -19,28 +19,3 @@ void zig_panic(const char *format, ...) {
va_end(ap);
abort();
}
char *zig_alloc_sprintf(int *len, const char *format, ...) {
va_list ap, ap2;
va_start(ap, format);
va_copy(ap2, ap);
int len1 = vsnprintf(nullptr, 0, format, ap);
assert(len1 >= 0);
size_t required_size = len1 + 1;
char *mem = allocate<char>(required_size);
if (!mem)
return nullptr;
int len2 = vsnprintf(mem, required_size, format, ap2);
assert(len2 == len1);
va_end(ap2);
va_end(ap);
if (len)
*len = len1;
return mem;
}