MasonProtter / Bumper.jl

Bring Your Own Stack
MIT License
152 stars 6 forks source link

Make `AllocBuffer` just store a pointer made (by default) by `malloc` #25

Open MasonProtter opened 9 months ago

MasonProtter commented 9 months ago

I'm not sure there's much advantage to me letting people wrap whatever type like like for this thing. Might be better to simply do:

mutable struct AllocBuffer
    ptr::Ptr{UInt8}
    length::Int
    offset::UInt8
end

function AllocBuffer(length::Int; finalize=true)
    ptr = malloc(length)
    out = AllocBuffer(ptr, length, UInt(0))
    if finalize
        finalizer(x -> free(x.ptr), out)
    end
    out
end

which'd make it more similar to SlabBuffer. This'd be a breaking change, so I'd like to do it before 1.0 if I do it.