diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-02-06 20:54:25 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-02-06 20:54:25 +0200 |
commit | 4ba6a3027d7a5d8c17abeb031622389f8be234fe (patch) | |
tree | 3c2fdba47e9b9c11a0e3b0996c9f733abb4c07c1 /pb_encode.h | |
parent | 39b8a5e2bbd5da85f23b48280e81a5ce6672b09d (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_encode.h')
-rw-r--r-- | pb_encode.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pb_encode.h b/pb_encode.h index 85a8297..69b88e8 100644 --- a/pb_encode.h +++ b/pb_encode.h @@ -32,7 +32,17 @@ extern "C" { */ struct _pb_ostream_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. + * Also, NULL pointer marks a 'sizing stream' that does not + * write anything. + */ + int *callback; +#else bool (*callback)(pb_ostream_t *stream, const uint8_t *buf, size_t count); +#endif void *state; /* Free field for use by callback implementation */ size_t max_size; /* Limit number of output bytes written (or use SIZE_MAX). */ size_t bytes_written; |