From e8878ba0bf7b9577978ff40f95831e017a8f5692 Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Sun, 27 Dec 2020 15:19:00 +0100 Subject: require the callers to provide a 0-terminated string --- sqlite.zig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'sqlite.zig') diff --git a/sqlite.zig b/sqlite.zig index 9d0fae2..395af30 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -31,7 +31,7 @@ pub const Db = struct { /// Mode determines how the database will be opened. pub const Mode = union(enum) { - File: []const u8, + File: [:0]const u8, Memory, }; @@ -45,13 +45,9 @@ pub const Db = struct { .File => |path| { logger.info("opening {}", .{path}); - // Need a null-terminated string here. - const pathZ = try allocator.dupeZ(u8, path); - defer allocator.free(pathZ); - var db: ?*c.sqlite3 = undefined; const result = c.sqlite3_open_v2( - pathZ, + path, &db, c.SQLITE_OPEN_READWRITE | c.SQLITE_OPEN_CREATE, null, -- cgit v1.2.3