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

Static buffers implementation #16

Open
d21d3q opened this issue Aug 10, 2017 · 3 comments
Open

Static buffers implementation #16

d21d3q opened this issue Aug 10, 2017 · 3 comments

Comments

@d21d3q
Copy link
Contributor

d21d3q commented Aug 10, 2017

How about making this library able to use static buffers?
I am playing with them now on this branch. For now I've added b64_encode_static because it has different parameters set, but ideally would be to make one entry point with optional (nullable) parameter for output buffer, so b64_encode would look like this.
Another thing would be introduce some macro (eg B64_STATIC_BUFFERS_ONLY) which would exclude code for dynamic memory allocation. Have a look at nanopb library. Quite big, but in can run both with dynamic memory allocation and without (excluded at compilation time).

Motivation for this is performance improvement - I am currently making project which is translating some serial protocol into another (with human readable frames) so that calling malloc and free for every single incoming byte seems to be overhead for this task.

@jwerle
Copy link
Owner

jwerle commented Aug 10, 2017

@d21d3q looks good!

@d21d3q
Copy link
Contributor Author

d21d3q commented Aug 11, 2017

So you don't mind breaking backward compatibility?
On the other hand incrementing major version number will do the job.

@jwerle
Copy link
Owner

jwerle commented Aug 11, 2017

@d21d3q in this case, no I do not. The less malloc calls this implementation can make, the better

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

No branches or pull requests

2 participants