Skip to content

Instantly share code, notes, and snippets.

View AshishBhattarai's full-sized avatar

Ashish Bhattarai AshishBhattarai

View GitHub Profile
@AshishBhattarai
AshishBhattarai / tlsf.zig
Last active April 25, 2024 17:00
Two-Level Segregated Fit memory allocator
const std = @import("std");
const Allocator = std.mem.Allocator;
const MemoryPool = std.heap.MemoryPool;
pub fn bit_scan_msb(mask: usize) u8 {
return 63 - @clz(mask);
}
pub fn bit_scan_lsb(mask: usize) u8 {
return @ctz(mask);
}