diff options
author | jospaeth <spaethj@in.tum.de> | 2020-08-07 10:48:30 +0200 |
---|---|---|
committer | jospaeth <spaethj@in.tum.de> | 2020-08-07 10:48:30 +0200 |
commit | 41cfd97254ab205c8405f21900d26a6c2ab88127 (patch) | |
tree | 01bea37b0de2e05cb8732d59661588903bda288c /src/util | |
parent | 90e87e4a0fc1a4673341e948a5eedd0d9a1d60ea (diff) | |
parent | 05004fd89f45d6e9bc4be81a34d340b1fb522196 (diff) | |
download | gnunet-41cfd97254ab205c8405f21900d26a6c2ab88127.tar.gz gnunet-41cfd97254ab205c8405f21900d26a6c2ab88127.zip |
Merge branch 'master' into spaeth/escrow_plugins
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/buffer.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/util/buffer.c b/src/util/buffer.c index 8fb10c2a5..662e4d0f2 100644 --- a/src/util/buffer.c +++ b/src/util/buffer.c | |||
@@ -32,7 +32,8 @@ | |||
32 | * @param capacity the capacity (in bytes) to allocate for @a buf | 32 | * @param capacity the capacity (in bytes) to allocate for @a buf |
33 | */ | 33 | */ |
34 | void | 34 | void |
35 | GNUNET_buffer_prealloc (struct GNUNET_Buffer *buf, size_t capacity) | 35 | GNUNET_buffer_prealloc (struct GNUNET_Buffer *buf, |
36 | size_t capacity) | ||
36 | { | 37 | { |
37 | /* Buffer should be zero-initialized */ | 38 | /* Buffer should be zero-initialized */ |
38 | GNUNET_assert (0 == buf->mem); | 39 | GNUNET_assert (0 == buf->mem); |
@@ -257,25 +258,25 @@ GNUNET_buffer_write_vfstr (struct GNUNET_Buffer *buf, | |||
257 | * | 258 | * |
258 | * @param buf buffer to write to | 259 | * @param buf buffer to write to |
259 | * @param data data to read from | 260 | * @param data data to read from |
260 | * @param len number of bytes to copy from @a data to @a buf | 261 | * @param data_len number of bytes to copy from @a data to @a buf |
261 | */ | 262 | */ |
262 | void | 263 | void |
263 | GNUNET_buffer_write_data_encoded (struct GNUNET_Buffer *buf, | 264 | GNUNET_buffer_write_data_encoded (struct GNUNET_Buffer *buf, |
264 | const char *data, | 265 | const void *data, |
265 | size_t len) | 266 | size_t data_len) |
266 | { | 267 | { |
267 | size_t outlen = len * 8; | 268 | size_t outlen = data_len * 8; |
268 | 269 | ||
269 | if (outlen % 5 > 0) | 270 | if (outlen % 5 > 0) |
270 | outlen += 5 - outlen % 5; | 271 | outlen += 5 - outlen % 5; |
271 | outlen /= 5; | 272 | outlen /= 5; |
272 | 273 | GNUNET_buffer_ensure_remaining (buf, | |
273 | GNUNET_buffer_ensure_remaining (buf, outlen); | 274 | outlen); |
274 | GNUNET_assert (NULL != | 275 | GNUNET_assert (NULL != |
275 | GNUNET_STRINGS_data_to_string (data, | 276 | GNUNET_STRINGS_data_to_string (data, |
276 | len, | 277 | data_len, |
277 | (buf->mem + | 278 | (buf->mem |
278 | buf->position), | 279 | + buf->position), |
279 | outlen)); | 280 | outlen)); |
280 | buf->position += outlen; | 281 | buf->position += outlen; |
281 | GNUNET_assert (buf->position <= buf->capacity); | 282 | GNUNET_assert (buf->position <= buf->capacity); |