summaryrefslogtreecommitdiffstats
path: root/pb_decode.h
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-02-06 20:54:25 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-02-06 20:54:25 +0200
commit4ba6a3027d7a5d8c17abeb031622389f8be234fe (patch)
tree3c2fdba47e9b9c11a0e3b0996c9f733abb4c07c1 /pb_decode.h
parent39b8a5e2bbd5da85f23b48280e81a5ce6672b09d (diff)
Add compile-time option PB_BUFFER_ONLY.
This allows slight optimizations if only memory buffer support (as opposed to stream callbacks) is wanted. On ARM difference is -12% execution time, -4% code size when enabled.
Diffstat (limited to 'pb_decode.h')
-rw-r--r--pb_decode.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/pb_decode.h b/pb_decode.h
index e9f8ced8..35de0a22 100644
--- a/pb_decode.h
+++ b/pb_decode.h
@@ -32,7 +32,16 @@ extern "C" {
*/
struct _pb_istream_t
{
+#ifdef PB_BUFFER_ONLY
+ /* Callback pointer is not used in buffer-only configuration.
+ * Having an int pointer here allows binary compatibility but
+ * gives an error if someone tries to assign callback function.
+ */
+ int *callback;
+#else
bool (*callback)(pb_istream_t *stream, uint8_t *buf, size_t count);
+#endif
+
void *state; /* Free field for use by callback implementation */
size_t bytes_left;