summaryrefslogtreecommitdiff
path: root/src/wasm-stack-allocator.c
diff options
context:
space:
mode:
authorBen Smith <binji@chromium.org>2016-04-15 01:20:24 -0700
committerBen Smith <binji@chromium.org>2016-04-15 01:20:24 -0700
commit30a62b7348a529e79008b6bf4bd72783dcd10d7b (patch)
treecaa493c7999ca7bf989ed7d4d8ba02248f6f12ef /src/wasm-stack-allocator.c
parent7c1ebc333ff50a7b8c0a5e6469ce518c9a3d47bd (diff)
downloadwabt-30a62b7348a529e79008b6bf4bd72783dcd10d7b.tar.gz
wabt-30a62b7348a529e79008b6bf4bd72783dcd10d7b.tar.bz2
wabt-30a62b7348a529e79008b6bf4bd72783dcd10d7b.zip
error handling for binary readers
Also, some logging cleanup in the binary readers.
Diffstat (limited to 'src/wasm-stack-allocator.c')
-rw-r--r--src/wasm-stack-allocator.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/wasm-stack-allocator.c b/src/wasm-stack-allocator.c
index 47817910..b3638b97 100644
--- a/src/wasm-stack-allocator.c
+++ b/src/wasm-stack-allocator.c
@@ -22,6 +22,12 @@
#define WASM_TRACE_ALLOCATOR 0
+#if WASM_TRACE_ALLOCATOR
+#define TRACEF(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define TRACEF(...)
+#endif
+
#if WASM_STACK_ALLOCATOR_STATS
#include <stdio.h>
#endif /* WASM_STACK_ALLOCATOR_STATS */
@@ -126,8 +132,8 @@ static void* stack_alloc(WasmAllocator* allocator,
#if WASM_TRACE_ALLOCATOR
if (file) {
- fprintf(stderr, "%s:%d: stack_alloc(%" PRIzd ", align=%" PRIzd ") => %p\n",
- file, line, size, align, result);
+ TRACEF("%s:%d: stack_alloc(%" PRIzd ", align=%" PRIzd ") => %p\n", file,
+ line, size, align, result);
}
#endif /* WASM_TRACE_ALLOCATOR */
@@ -163,9 +169,8 @@ static void* stack_realloc(WasmAllocator* allocator,
#if WASM_TRACE_ALLOCATOR
if (file) {
- fprintf(stderr,
- "%s:%d: stack_realloc(%p, %" PRIzd ", align=%" PRIzd ") => %p\n",
- file, line, p, size, align, result);
+ TRACEF("%s:%d: stack_realloc(%p, %" PRIzd ", align=%" PRIzd ") => %p\n",
+ file, line, p, size, align, result);
}
#endif /* WASM_TRACE_ALLOCATOR */
@@ -193,10 +198,7 @@ static void stack_free(WasmAllocator* allocator,
if (!p)
return;
-#if WASM_TRACE_ALLOCATOR
- fprintf(stderr, "%s:%d: stack_free(%p)\n", file, line, p);
-#endif /* WASM_TRACE_ALLOCATOR */
-
+ TRACEF("%s:%d: stack_free(%p)\n", file, line, p);
WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
#if WASM_STACK_ALLOCATOR_STATS