aboutsummaryrefslogtreecommitdiff
path: root/src/util/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/buffer.c')
-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 2af972413..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 char *p = buf->mem + buf->position;
269 269
270 if (outlen % 5 > 0) 270 if (outlen % 5 > 0)
271 outlen += 5 - outlen % 5; 271 outlen += 5 - outlen % 5;
272 outlen /= 5; 272 outlen /= 5;
273 273 GNUNET_buffer_ensure_remaining (buf,
274 GNUNET_buffer_ensure_remaining (buf, outlen); 274 outlen);
275 GNUNET_assert (NULL != 275 GNUNET_assert (NULL !=
276 GNUNET_STRINGS_data_to_string (data, 276 GNUNET_STRINGS_data_to_string (data,
277 len, 277 data_len,
278 p, 278 (buf->mem
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);