aboutsummaryrefslogtreecommitdiff
path: root/lib/std/json.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-11-27 01:07:35 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-11-29 23:30:38 -0700
commitceb0a632cfd6a4eada6bd27bf6a3754e95dcac86 (patch)
tree3c174281ab0b9d51b6c78234b0648e197412eea8 /lib/std/json.zig
parentdeda6b514691c3a7ffc7931469886d0e7be2f67e (diff)
downloadzig-ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86.tar.gz
zig-ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86.zip
std.mem.Allocator: allow shrink to fail
closes #13535
Diffstat (limited to 'lib/std/json.zig')
-rw-r--r--lib/std/json.zig6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/std/json.zig b/lib/std/json.zig
index 87fe1c9dea..5a40278e52 100644
--- a/lib/std/json.zig
+++ b/lib/std/json.zig
@@ -1668,12 +1668,10 @@ fn parseInternal(
if (ptrInfo.sentinel) |some| {
const sentinel_value = @ptrCast(*align(1) const ptrInfo.child, some).*;
- try arraylist.append(sentinel_value);
- const output = arraylist.toOwnedSlice();
- return output[0 .. output.len - 1 :sentinel_value];
+ return try arraylist.toOwnedSliceSentinel(sentinel_value);
}
- return arraylist.toOwnedSlice();
+ return try arraylist.toOwnedSlice();
},
.String => |stringToken| {
if (ptrInfo.child != u8) return error.UnexpectedToken;