less memory thrashing

This commit is contained in:
2022-03-05 05:33:31 +02:00
committed by Motiejus Jakštys
parent 87c424aab9
commit 869f3f3a65
3 changed files with 15 additions and 13 deletions

View File

@@ -28,6 +28,7 @@ pub fn pack(allocator: Allocator, input: [][*:0]const u8) Error![]const u8 {
const size = c.cmph_packed_size(hash);
var buf = try allocator.alloc(u8, size);
errdefer allocator.free(buf);
c.cmph_pack(hash, &buf[0]);
c.cmph_destroy(hash);
return buf[4..];