mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
init allocator in main
This commit is contained in:
parent
7373a76f81
commit
52f6c30173
1 changed files with 6 additions and 3 deletions
|
@ -1,7 +1,13 @@
|
|||
const std = @import("std");
|
||||
const sort = @import("sort.zig");
|
||||
|
||||
var gpa: std.heap.GeneralPurposeAllocator(.{}) = undefined;
|
||||
var allocator: std.mem.Allocator = undefined;
|
||||
|
||||
pub fn main() !void {
|
||||
gpa = .{};
|
||||
allocator = gpa.allocator();
|
||||
|
||||
const size = 1000000;
|
||||
var arr_ptr: [*]i64 = @alignCast(@ptrCast(testing_roc_alloc(size * @sizeOf(i64), @alignOf(i64))));
|
||||
defer testing_roc_dealloc(arr_ptr, @alignOf(i64));
|
||||
|
@ -48,9 +54,6 @@ comptime {
|
|||
@export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong });
|
||||
}
|
||||
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
fn testing_roc_alloc(size: usize, _: u32) callconv(.C) ?*anyopaque {
|
||||
// We store an extra usize which is the size of the full allocation.
|
||||
const full_size = size + @sizeOf(usize);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue