shorten cmph pack by 4 bytes
This commit is contained in:
@@ -6,8 +6,9 @@ const c = @cImport({
|
||||
@cInclude("cmph.h");
|
||||
});
|
||||
|
||||
// pack packs cmph hashes for the given input and returns a slice ("cmph
|
||||
// userdata") for further storage. The slice must be freed by the caller.
|
||||
// pack packs cmph hashes for the given input and returns a slice ("cmph pack
|
||||
// minus first 4 bytes") for further storage. The slice must be freed by the
|
||||
// caller.
|
||||
const packErr = Allocator.Error || error{Overflow};
|
||||
pub fn pack(allocator: Allocator, input: [][*:0]const u8) packErr![]const u8 {
|
||||
var cvector = @ptrCast([*c][*c]u8, input.ptr);
|
||||
@@ -24,7 +25,7 @@ pub fn pack(allocator: Allocator, input: [][*:0]const u8) packErr![]const u8 {
|
||||
var buf = try allocator.alloc(u8, size);
|
||||
c.cmph_pack(hash, &buf[0]);
|
||||
c.cmph_destroy(hash);
|
||||
return buf;
|
||||
return buf[4..];
|
||||
}
|
||||
|
||||
const testing = std.testing;
|
||||
|
||||
Reference in New Issue
Block a user