From 3a7222b86ca8b80ee9cb6a11a2f5b2d95eab7195 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 6 Jul 2022 18:12:33 -0700 Subject: [PATCH] strings: proper ArrayList usage --- src/strings.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/strings.zig b/src/strings.zig index 76ccbd1..1edbfd4 100644 --- a/src/strings.zig +++ b/src/strings.zig @@ -2,8 +2,8 @@ const std = @import("std"); const string = []const u8; pub fn splitAlloc(alloc: std.mem.Allocator, input: string, delim: string) ![]const string { - const result = &std.ArrayList(string).init(alloc); - defer result.deinit(); + var result = std.ArrayList(string).init(alloc); + errdefer result.deinit(); var it = std.mem.split(u8, input, delim); while (it.next()) |item| { try result.append(item);