Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MasonProtter opened this issue Nov 9, 2023 · 0 comments
Open

Comments

@MasonProtter
Copy link
Owner

MasonProtter commented Nov 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant