1
Fork 0
turbonss/src/bdz.zig

13 lines
396 B
Zig
Raw Normal View History

2022-02-23 15:25:55 +02:00
const std = @import("std");
const Allocator = std.mem.Allocator;
const c = @cImport({
@cInclude("bdz.h");
});
pub fn search_packed(packed_mphf: []const u8, key: []const u8) error{Overflow}!u32 {
2022-02-23 20:30:23 +02:00
const bdz_start = @intToPtr(?*anyopaque, @ptrToInt(&packed_mphf[0]));
2022-02-23 15:25:55 +02:00
const len = try std.math.cast(c_uint, key.len);
return @as(u32, c.bdz_search_packed(bdz_start, key.ptr, len));
}