43 buf->capacity = capacity;
58 size_t new_capacity =
buf->position + n;
62 if (new_capacity <= buf->capacity)
66 if (new_capacity < buf->capacity * 2)
67 new_capacity =
buf->capacity * 2;
68 buf->capacity = new_capacity;
106 size_t len = strlen (str);
128 if ( (0 ==
buf->position) || (
'\0' !=
buf->mem[
buf->position - 1]))
131 buf->mem[
buf->position++] =
'\0';
182 size_t len = strlen (str);
184 while ( (0 !=
len) && (
'/' == str[0]) )
189 if ( (0 ==
buf->position) || (
'/' !=
buf->mem[
buf->position - 1]) )
192 buf->mem[
buf->position++] =
'/';
213 va_start (
args, fmt);
237 va_copy (args2,
args);
238 res = vsnprintf (NULL, 0, fmt, args2);
244 va_copy (args2,
args);
245 res = vsnprintf (
buf->mem +
buf->position,
res + 1, fmt, args2);
268 size_t outlen = data_len * 8;
271 outlen += 5 - outlen % 5;
281 buf->position += outlen;
void GNUNET_buffer_write_fstr(struct GNUNET_Buffer *buf, const char *fmt,...)
Write a 0-terminated formatted string to a buffer, excluding the 0-terminator.
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
char * GNUNET_buffer_reap_str(struct GNUNET_Buffer *buf)
Clear the buffer and return the string it contained.
void * GNUNET_buffer_reap(struct GNUNET_Buffer *buf, size_t *size)
Clear the buffer and return its contents.
void GNUNET_buffer_write_data_encoded(struct GNUNET_Buffer *buf, const void *data, size_t data_len)
Write data encoded via GNUNET_STRINGS_data_to_string to the buffer.
void GNUNET_buffer_ensure_remaining(struct GNUNET_Buffer *buf, size_t n)
Make sure that at least n bytes remaining in the buffer.
void GNUNET_buffer_write_vfstr(struct GNUNET_Buffer *buf, const char *fmt, va_list args)
Write a 0-terminated formatted string to a buffer, excluding the 0-terminator.
void GNUNET_buffer_write(struct GNUNET_Buffer *buf, const char *data, size_t len)
Write bytes to the buffer.
void GNUNET_buffer_prealloc(struct GNUNET_Buffer *buf, size_t capacity)
Initialize a buffer with the given capacity.
void GNUNET_buffer_write_path(struct GNUNET_Buffer *buf, const char *str)
Write a path component to a buffer, ensuring that there is exactly one slash between the previous con...
void GNUNET_buffer_write_str(struct GNUNET_Buffer *buf, const char *str)
Write a 0-terminated string to a buffer, excluding the 0-terminator.
void GNUNET_buffer_clear(struct GNUNET_Buffer *buf)
Free the backing memory of the given buffer.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_STRINGS_data_to_string(const void *data, size_t size, char *out, size_t out_size)
Convert binary data to ASCII encoding using CrockfordBase32.
static unsigned int size
Size of the "table".
Dynamically growing buffer.