Skip to content

Commit

Permalink
move addSentinel into zig-extras
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro committed Aug 27, 2021
1 parent a0d194e commit b735c32
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/db/_.zig
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
const std = @import("std");
const zorm = @import("zorm");
const extras = @import("extras");

const _internal = @import("./_internal.zig");
const db = &_internal.db;
const Engine = _internal.Engine;

pub fn connect(alloc: *std.mem.Allocator, path: []const u8) !void {
const abspath = try std.fs.realpathAlloc(alloc, path);
const nulpath = try addSentinel(alloc, u8, abspath, 0);
const nulpath = try extras.addSentinel(alloc, u8, abspath, 0);
db.* = try Engine.connect(nulpath);
}

pub fn close() void {
db.close();
}

fn addSentinel(alloc: *std.mem.Allocator, comptime T: type, input: []const T, comptime sentinel: T) ![:sentinel]const T {
var list = try std.ArrayList(T).initCapacity(alloc, input.len + 1);
try list.appendSlice(input);
try list.append(sentinel);
const str = list.toOwnedSlice();
return str[0 .. str.len - 1 :sentinel];
}

pub const Remote = @import("./Remote.zig").Remote;
pub const User = @import("./User.zig").User;
pub const Package = @import("./Package.zig").Package;
Expand Down
2 changes: 1 addition & 1 deletion zigmod.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ git https://github.com/nektro/zig-range commit-890ca308fe09b3d5c866d5cfb3b3d7a95
git https://github.com/kivikakk/htmlentities.zig commit-c3cbe4cb3a9a9bd60e7c9fedcf9b97e087b98d6c
git https://github.com/nektro/zig-zorm commit-38a255e5698796eb13a171a6ce6f33b98d65cfe2
git https://github.com/vrischmann/zig-sqlite commit-e9966b721515864ce6397aa8f35038ed318c97e7
git https://github.com/nektro/zig-extras commit-8691b110468d7b6d170e6fec0e0ecfe7ede6372c
git https://github.com/nektro/zig-extras commit-4d2b9a70c8347fd5ce877eb087e1b3cad54e3cae

0 comments on commit b735c32

Please sign in to comment.