diff options
-rw-r--r-- | pb_decode.c | 7 | ||||
-rw-r--r-- | pb_encode.c | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/pb_decode.c b/pb_decode.c index 7c68b5a2..6ddde773 100644 --- a/pb_decode.c +++ b/pb_decode.c @@ -39,11 +39,14 @@ static const pb_decoder_t PB_DECODERS[PB_LTYPES_COUNT] = { static bool checkreturn buf_read(pb_istream_t *stream, uint8_t *buf, size_t count) { uint8_t *source = (uint8_t*)stream->state; + stream->state = source + count; if (buf != NULL) - memcpy(buf, source, count); + { + while (count--) + *buf++ = *source++; + } - stream->state = source + count; return true; } diff --git a/pb_encode.c b/pb_encode.c index 5d1965d1..95223cb6 100644 --- a/pb_encode.c +++ b/pb_encode.c @@ -37,8 +37,11 @@ static const pb_encoder_t PB_ENCODERS[PB_LTYPES_COUNT] = { static bool checkreturn buf_write(pb_ostream_t *stream, const uint8_t *buf, size_t count) { uint8_t *dest = (uint8_t*)stream->state; - memcpy(dest, buf, count); stream->state = dest + count; + + while (count--) + *dest++ = *buf++; + return true; } |