aboutsummaryrefslogtreecommitdiff
path: root/std/debug.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-11-10 14:02:45 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-11-10 14:17:23 -0500
commit1ac46fac15953820948b77b94083828f84673641 (patch)
tree057f8630fc4db8bc02e5e4a56d483d75fcc23fe9 /std/debug.zig
parent336d81894da2c34a77cffd1bf903ad9e4dcaa7aa (diff)
downloadzig-1ac46fac15953820948b77b94083828f84673641.tar.gz
zig-1ac46fac15953820948b77b94083828f84673641.zip
add a std lib test for reading and writing files
* fix fstat wrong on darwin * move std.debug.global_allocator to std.debug.global_allocator_state and make it private * add std.debug.global_allocator as a pointer (to upgrade your zig code remove the '&')
Diffstat (limited to 'std/debug.zig')
-rw-r--r--std/debug.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/std/debug.zig b/std/debug.zig
index 23e951219a..50322024c3 100644
--- a/std/debug.zig
+++ b/std/debug.zig
@@ -38,7 +38,7 @@ fn getStderrStream() -> %&io.OutStream {
/// Tries to print a stack trace to stderr, unbuffered, and ignores any error returned.
pub fn dumpStackTrace() {
const stderr = getStderrStream() %% return;
- writeStackTrace(stderr, &global_allocator, stderr_file.isTty(), 1) %% return;
+ writeStackTrace(stderr, global_allocator, stderr_file.isTty(), 1) %% return;
}
/// This function invokes undefined behavior when `ok` is `false`.
@@ -86,7 +86,7 @@ pub fn panic(comptime format: []const u8, args: ...) -> noreturn {
const stderr = getStderrStream() %% os.abort();
stderr.print(format ++ "\n", args) %% os.abort();
- writeStackTrace(stderr, &global_allocator, stderr_file.isTty(), 1) %% os.abort();
+ writeStackTrace(stderr, global_allocator, stderr_file.isTty(), 1) %% os.abort();
os.abort();
}
@@ -967,7 +967,8 @@ fn readILeb128(in_stream: &io.InStream) -> %i64 {
}
}
-pub var global_allocator = mem.Allocator {
+pub const global_allocator = &global_allocator_state;
+var global_allocator_state = mem.Allocator {
.allocFn = globalAlloc,
.reallocFn = globalRealloc,
.freeFn = globalFree,