Skip to content

Commit

Permalink
strings: proper ArrayList usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro committed Jul 7, 2022
1 parent 51538f1 commit 3a7222b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/strings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3a7222b

Please sign in to comment.