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

Add open flag to transfer ownership of array buffers #176

Closed
jeromekelleher opened this issue Dec 3, 2021 · 2 comments · Fixed by #179
Closed

Add open flag to transfer ownership of array buffers #176

jeromekelleher opened this issue Dec 3, 2021 · 2 comments · Fixed by #179
Assignees

Comments

@jeromekelleher
Copy link
Member

When kastore_gets returns an array buffer it's giving back a pointer that is owned by the kastore. After #175, all array pointers returned will be individually malloced buffers, which client code may wish to take ownership of to avoid extra copies.

We need to add a flag to kas_open() which indicates that a call to kastore_get involves the transfer of ownership of the buffer from kastore to the client. Once an item has been successfully returned to the client we set a flag on the struct saying "don't free this buffer", so that fields that are not retrieved don't result in a memory leak.

What do we call this flag? Say, KAS_GET_OWNS_ARRAY?

@jeromekelleher jeromekelleher added this to the C version 2.1.0 milestone Dec 3, 2021
@jeromekelleher jeromekelleher changed the title Add open flag to transfer ownership of buffers Add open flag to transfer ownership of array buffers Dec 3, 2021
@benjeffery
Copy link
Member

If we want to use similar language to tskit then I guess KAS_GET_TRANSFERS_OWNERSHIP?

@jeromekelleher
Copy link
Member Author

Yes, good idea.

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

Successfully merging a pull request may close this issue.

2 participants