aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-08-07 10:48:30 +0200
committerjospaeth <spaethj@in.tum.de>2020-08-07 10:48:30 +0200
commit41cfd97254ab205c8405f21900d26a6c2ab88127 (patch)
tree01bea37b0de2e05cb8732d59661588903bda288c /src/util
parent90e87e4a0fc1a4673341e948a5eedd0d9a1d60ea (diff)
parent05004fd89f45d6e9bc4be81a34d340b1fb522196 (diff)
downloadgnunet-41cfd97254ab205c8405f21900d26a6c2ab88127.tar.gz
gnunet-41cfd97254ab205c8405f21900d26a6c2ab88127.zip
Merge branch 'master' into spaeth/escrow_plugins
Diffstat (limited to 'src/util')
-rw-r--r--src/util/buffer.c21
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 */
34void 34void
35GNUNET_buffer_prealloc (struct GNUNET_Buffer *buf, size_t capacity) 35GNUNET_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 */
262void 263void
263GNUNET_buffer_write_data_encoded (struct GNUNET_Buffer *buf, 264GNUNET_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);