authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-07 19:17:10 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-07 19:17:10 -07:00
logcaaf5d24b97c2f016c5c44131cd5b8507d1d5082
treee8fc459b7a13b4668994a93c36872c0d815b25b1
parent38a255e5698796eb13a171a6ce6f33b98d65cfe2

sqlite: use the alloc versions of more methods


1 files changed, 3 insertions(+), 3 deletions(-)

src/sqlite3.zig+3-3
...@@ -27,7 +27,7 @@ pub fn close(self: *Self) void {...@@ -27,7 +27,7 @@ pub fn close(self: *Self) void {
27pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: []const u8, args: anytype) ![]const T {27pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: []const u8, args: anytype) ![]const T {
28 var stmt = try self.db.prepare(query);28 var stmt = try self.db.prepare(query);
29 defer stmt.deinit();29 defer stmt.deinit();
30 var iter = try stmt.iterator(T, args);30 var iter = try stmt.iteratorAlloc(T, alloc, args);
31 var list = std.ArrayList(T).init(alloc);31 var list = std.ArrayList(T).init(alloc);
32 while (try iter.nextAlloc(alloc, .{})) |row| {32 while (try iter.nextAlloc(alloc, .{})) |row| {
33 try list.append(row);33 try list.append(row);
...@@ -35,10 +35,10 @@ pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptim...@@ -35,10 +35,10 @@ pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptim
35 return list.toOwnedSlice();35 return list.toOwnedSlice();
36}36}
3737
38pub fn exec(self: *Self, comptime query: []const u8, args: anytype) !void {38pub fn exec(self: *Self, alloc: *std.mem.Allocator, comptime query: []const u8, args: anytype) !void {
39 var stmt = try self.db.prepare(query);39 var stmt = try self.db.prepare(query);
40 defer stmt.deinit();40 defer stmt.deinit();
41 try stmt.exec(args);41 try stmt.execAlloc(.{ .allocator = alloc }, args);
42}42}
4343
44pub fn first(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: []const u8, args: anytype) !?T {44pub fn first(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: []const u8, args: anytype) !?T {