rxi / vec

A type-safe dynamic array implementation for C
MIT License
452 stars 62 forks source link

Custom Memory Allocator Support #14

Open ForeverZer0 opened 4 years ago

ForeverZer0 commented 4 years ago

I am unsure if this project is still actively maintained, though I thought I would create the issue as it is still used in code today.

I wanted to propose the addition of support for custom memory allocation and freeing, just a simple set of macros (i.e. VEC_MALLOC, VEC_FREE, etc.). When such macros are defined, the library will use them in place of the default ones.

It is obviously trivial for users to add this behavior themselves with a few quick find/replace in the editor, I just thought it would be a nice feature to have out of the box that could be easily added without too much effort.

If you are willing to accept pull-requests, I would be happy to issue one for it. Either way, thank you for sharing :)

mobius3 commented 3 years ago

Create the pull request, it might be useful for others, even if it's not accepted. Having a "context' passed in to these custom allocators would be useful too (which is my case)

ForeverZer0 commented 3 years ago

@mobius3 You make a good point. I don't believe there are any current maintainers, but I did issue the PR #16 anyways if anyone else ever stumbles across this issue and is interested.