diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-05-01 06:15:58 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-05-01 06:47:56 -0400 |
| commit | 87668211578b843571d6819fddde944328a05f89 (patch) | |
| tree | 68cfe7fcdeaab2fef3d56260c23e0d965a056d56 /lib/std/testing.zig | |
| parent | 1d202008d8008681988effdf25be2c6a753cf067 (diff) | |
| download | zig-87668211578b843571d6819fddde944328a05f89.tar.gz zig-87668211578b843571d6819fddde944328a05f89.zip | |
rework std.math.big.Int
Now there are 3 types:
* std.math.big.int.Const
- the memory is immutable, only stores limbs and is_positive
- all methods operating on constant data go here
* std.math.big.int.Mutable
- the memory is mutable, stores capacity in addition to limbs and
is_positive
- methods here have some Mutable parameters and some Const
parameters. These methods expect callers to pre-calculate the
amount of resources required, and asserts that the resources are
available.
* std.math.big.int.Managed
- the memory is mutable and additionally stores an allocator.
- methods here perform the resource calculations for the programmer.
- this is the high level abstraction from before
Each of these 3 types can be converted to the other ones.
You can see the use case for this in the self-hosted compiler, where we
only store limbs, and construct the big ints as needed.
This gets rid of the hack where the allocator was optional and the
notion of "fixed" versions of the struct. Such things are now modeled
with the `big.int.Const` type.
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 5b72533057..0f6cefb787 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -12,7 +12,7 @@ pub const failing_allocator = &failing_allocator_instance.allocator; pub var failing_allocator_instance = FailingAllocator.init(&base_allocator_instance.allocator, 0); pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]); -var allocator_mem: [1024 * 1024]u8 = undefined; +var allocator_mem: [2 * 1024 * 1024]u8 = undefined; /// This function is intended to be used only in tests. It prints diagnostics to stderr /// and then aborts when actual_error_union is not expected_error. |
