sheredom / utf8.h

📚 single header utf8 string functions for C and C++
The Unlicense
1.69k stars 123 forks source link

Allow programmer specified allocator #84

Closed warmwaffles closed 3 years ago

warmwaffles commented 3 years ago

Would be nice to maybe provide a way for the person including the utf8 code to be able to do something like

#define utf8malloc my_alloc
#include "utf8.h"

I would make a PR to do this, but I don't know if it would be anything anyone is interested in.

sheredom commented 3 years ago

There is only two entry points utf8dup and utf8ndup that use malloc - I think I'd rather add utf8dup_ex that takes a user provided allocator to do this (similar to the user allocator in my other lib json.h. Thoughts?

warmwaffles commented 3 years ago

I think that would work too. Rationale is that I am using this library for some small stuff in an erlang NIF and would prefer to use erlang's allocator and deallocator there.