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

Custom memory allocators #14

Open
atticus5 opened this issue Jul 26, 2021 · 2 comments
Open

Custom memory allocators #14

atticus5 opened this issue Jul 26, 2021 · 2 comments

Comments

@atticus5
Copy link

Would like to also have the ability to define a custom memory allocator as we do for free and copy functions.

@glouw
Copy link
Owner

glouw commented Aug 6, 2021

Yes, all memory allocations are defined with malloc, so just override malloc with your own call. Remember to revert the malloc redef at the end. This can be done on a per container basis, so it's pretty useful!

void* my_malloc(size_t size) { .... }
#define malloc my_malloc
#define P
#define T int
#include <vec.h>
#undef my_malloc

@atticus5
Copy link
Author

atticus5 commented Aug 8, 2021

@glouw but can't do the same for free unfortunatelly, cause it is used as a suffix, unless I change 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

2 participants