aboutsummaryrefslogtreecommitdiff
path: root/std/debug.zig
diff options
context:
space:
mode:
Diffstat (limited to 'std/debug.zig')
-rw-r--r--std/debug.zig41
1 files changed, 3 insertions, 38 deletions
diff --git a/std/debug.zig b/std/debug.zig
index 3e7a38d043..25d6c84e0b 100644
--- a/std/debug.zig
+++ b/std/debug.zig
@@ -965,41 +965,6 @@ fn readILeb128(in_stream: &io.InStream) -> %i64 {
}
}
-pub const global_allocator = &global_allocator_state;
-
-var global_allocator_state = mem.Allocator {
- .allocFn = globalAlloc,
- .reallocFn = globalRealloc,
- .freeFn = globalFree,
-};
-
-pub var global_allocator_mem: [100 * 1024]u8 = undefined;
-pub var global_allocator_index: usize = 0;
-
-error OutOfMemory;
-
-fn globalAlloc(self: &mem.Allocator, n: usize, alignment: u29) -> %[]u8 {
- const addr = @ptrToInt(&global_allocator_mem[global_allocator_index]);
- const rem = @rem(addr, alignment);
- const march_forward_bytes = if (rem == 0) 0 else (alignment - rem);
- const adjusted_index = global_allocator_index + march_forward_bytes;
- const end_index = adjusted_index + n;
- if (end_index > global_allocator_mem.len) {
- return error.OutOfMemory;
- }
- const result = global_allocator_mem[adjusted_index .. end_index];
- global_allocator_index = end_index;
- return result;
-}
-
-fn globalRealloc(self: &mem.Allocator, old_mem: []u8, new_size: usize, alignment: u29) -> %[]u8 {
- if (new_size <= old_mem.len) {
- return old_mem[0..new_size];
- } else {
- const result = %return globalAlloc(self, new_size, alignment);
- @memcpy(result.ptr, old_mem.ptr, old_mem.len);
- return result;
- }
-}
-
-fn globalFree(self: &mem.Allocator, memory: []u8) { }
+pub const global_allocator = &global_fixed_allocator.allocator;
+var global_fixed_allocator = mem.FixedBufferAllocator.init(global_allocator_mem[0..]);
+var global_allocator_mem: [100 * 1024]u8 = undefined;