From a1c695f5be5178cefaa22aac22dff0480a29e61f Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Sun, 14 Apr 2024 19:26:44 +0200 Subject: all: use our workaround function for SQLITE_TRANSIENT --- helpers.zig | 8 ++++---- sqlite.zig | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helpers.zig b/helpers.zig index 7bb695e..b9a6131 100644 --- a/helpers.zig +++ b/helpers.zig @@ -13,8 +13,8 @@ pub fn setResult(ctx: ?*c.sqlite3_context, result: anytype) void { const ResultType = @TypeOf(result); switch (ResultType) { - Text => c.sqlite3_result_text(ctx, result.data.ptr, @intCast(result.data.len), c.SQLITE_TRANSIENT), - Blob => c.sqlite3_result_blob(ctx, result.data.ptr, @intCast(result.data.len), c.SQLITE_TRANSIENT), + Text => c.sqlite3_result_text(ctx, result.data.ptr, @intCast(result.data.len), c.sqliteTransientAsDestructor()), + Blob => c.sqlite3_result_blob(ctx, result.data.ptr, @intCast(result.data.len), c.sqliteTransientAsDestructor()), else => switch (@typeInfo(ResultType)) { .Int => |info| if ((info.bits + if (info.signedness == .unsigned) 1 else 0) <= 32) { c.sqlite3_result_int(ctx, result); @@ -26,12 +26,12 @@ pub fn setResult(ctx: ?*c.sqlite3_context, result: anytype) void { .Float => c.sqlite3_result_double(ctx, result), .Bool => c.sqlite3_result_int(ctx, if (result) 1 else 0), .Array => |arr| switch (arr.child) { - u8 => c.sqlite3_result_blob(ctx, &result, arr.len, c.SQLITE_TRANSIENT), + u8 => c.sqlite3_result_blob(ctx, &result, arr.len, c.sqliteTransientAsDestructor()), else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), }, .Pointer => |ptr| switch (ptr.size) { .Slice => switch (ptr.child) { - u8 => c.sqlite3_result_text(ctx, result.ptr, @intCast(result.len), c.SQLITE_TRANSIENT), + u8 => c.sqlite3_result_text(ctx, result.ptr, @intCast(result.len), c.sqliteTransientAsDestructor()), else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), }, else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), diff --git a/sqlite.zig b/sqlite.zig index be46dea..bd11dea 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -1676,7 +1676,7 @@ pub const DynamicStatement = struct { const data: []const u8 = field[0..field.len]; // NOTE(vincent): The array is temporary and must be copied, therefore we use SQLITE_TRANSIENT - const result = c.sqlite3_bind_text(self.stmt, column, data.ptr, @intCast(data.len), c.SQLITE_TRANSIENT); + const result = c.sqlite3_bind_text(self.stmt, column, data.ptr, @intCast(data.len), c.sqliteTransientAsDestructor()); return convertResultToError(result); }, else => @compileError("cannot bind field " ++ field_name ++ " of type array of " ++ @typeName(arr.child)), -- cgit v1.2.3