| author | |
| committer | |
| log | 01b9fa2c2574bd02937ce40525e94026c3acd551 |
| tree | 9dc57db34c1101496eb8353ffbdb00e9db115507 |
| parent | a72b584c765e0b714e40b55b43971d4b0d2ad8dd |
| signature |
2 files changed, 4 insertions(+), 1 deletions(-)
lib/std/math/big/int.zig+1| ... | @@ -2378,6 +2378,7 @@ pub const Managed = struct { | ... | @@ -2378,6 +2378,7 @@ pub const Managed = struct { |
| 2378 | /// This is identical to an `init`, followed by a `set`. | 2378 | /// This is identical to an `init`, followed by a `set`. |
| 2379 | pub fn initSet(allocator: Allocator, value: anytype) !Managed { | 2379 | pub fn initSet(allocator: Allocator, value: anytype) !Managed { |
| 2380 | var s = try Managed.init(allocator); | 2380 | var s = try Managed.init(allocator); |
| 2381 | errdefer s.deinit(); | ||
| 2381 | try s.set(value); | 2382 | try s.set(value); |
| 2382 | return s; | 2383 | return s; |
| 2383 | } | 2384 | } |
lib/std/math/big/rational.zig+3-1| ... | @@ -30,8 +30,10 @@ pub const Rational = struct { | ... | @@ -30,8 +30,10 @@ pub const Rational = struct { |
| 30 | /// Create a new Rational. A small amount of memory will be allocated on initialization. | 30 | /// Create a new Rational. A small amount of memory will be allocated on initialization. |
| 31 | /// This will be 2 * Int.default_capacity. | 31 | /// This will be 2 * Int.default_capacity. |
| 32 | pub fn init(a: Allocator) !Rational { | 32 | pub fn init(a: Allocator) !Rational { |
| 33 | var p = try Int.init(a); | ||
| 34 | errdefer p.deinit(); | ||
| 33 | return Rational{ | 35 | return Rational{ |
| 34 | .p = try Int.init(a), | 36 | .p = p, |
| 35 | .q = try Int.initSet(a, 1), | 37 | .q = try Int.initSet(a, 1), |
| 36 | }; | 38 | }; |
| 37 | } | 39 | } |