Skip to content
Snippets Groups Projects
Commit 3d361579 authored by Andrew Ruder's avatar Andrew Ruder
Browse files

pb_istream_from_buffer: add const to prototype

This commit changes the prototype for pb_istream_from_buffer from:
  pb_istream_t pb_istream_from_buffer(uint8_t *buf, size_t bufsize);
to
  pb_istream_t pb_istream_from_buffer(const uint8_t *buf, size_t bufsize);

This allows pb_istream_from_buffer users to point to const buffers
without having to inspect code (to ensure practical const-ness) and then be
forced to manually cast away const.

In order to not break compatibility with existing programs (by
introducing a const/non-const union in the pb_istream_t state) we simply
cast away the const in pb_istream_from_buffer and re-apply it when
possible in the callbacks.  Unfortunately we lose any compiler help in
the callbacks to ensure we are treating the buffer as const but manual
inspection is easy enough.
parent 56f7c488
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment