authorgravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2019-03-26 20:31:16+13:00
committergravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2019-04-11 19:36:35+12:00
logb3ecdfd7bfb9c6b3bd085b489fe20dd0ca1e12d8
tree95d48d81113c55e7dd4d828806218010dee037e4
parent5f4fcd5030fa93cf2518f98ffc666e4e4dc1052b

Fix big.Int toString maybe-null allocator


1 files changed, 4 insertions(+), 2 deletions(-)

std/math/big/int.zig+4-2
...@@ -449,9 +449,11 @@ pub const Int = struct {...@@ -449,9 +449,11 @@ pub const Int = struct {
449 comptime FmtError: type,449 comptime FmtError: type,
450 output: fn (@typeOf(context), []const u8) FmtError!void,450 output: fn (@typeOf(context), []const u8) FmtError!void,
451 ) FmtError!void {451 ) FmtError!void {
452 self.assertWritable();
452 // TODO look at fmt and support other bases453 // TODO look at fmt and support other bases
453 const str = self.toString(self.allocator, 10) catch @panic("TODO make this non allocating");454 // TODO support read-only fixed integers
454 defer self.allocator.free(str);455 const str = self.toString(self.allocator.?, 10) catch @panic("TODO make this non allocating");
456 defer self.allocator.?.free(str);
455 return output(context, str);457 return output(context, str);
456 }458 }
457459