![]() |
GNUnet
0.11.x
|
Go to the source code of this file.
Data Structures | |
struct | GNUNET_Buffer |
Common buffer management functions. More... | |
Functions | |
void | GNUNET_buffer_prealloc (struct GNUNET_Buffer *buf, size_t capacity) |
Initialize a buffer with the given capacity. More... | |
void | GNUNET_buffer_ensure_remaining (struct GNUNET_Buffer *buf, size_t n) |
Make sure that at least n bytes remaining in the buffer. More... | |
void | GNUNET_buffer_write (struct GNUNET_Buffer *buf, const char *data, size_t len) |
Write bytes to the buffer. More... | |
void | GNUNET_buffer_write_str (struct GNUNET_Buffer *buf, const char *str) |
Write a 0-terminated string to a buffer, excluding the 0-terminator. More... | |
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. More... | |
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 contents of the buffer and the new string. More... | |
void | GNUNET_buffer_write_fstr (struct GNUNET_Buffer *buf, const char *fmt,...) __attribute__((format(printf |
Write a 0-terminated formatted string to a buffer, excluding the 0-terminator. More... | |
void 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. More... | |
char * | GNUNET_buffer_reap_str (struct GNUNET_Buffer *buf) |
Clear the buffer and return the string it contained. More... | |
void * | GNUNET_buffer_reap (struct GNUNET_Buffer *buf, size_t *size) |
Clear the buffer and return its contents. More... | |
void | GNUNET_buffer_clear (struct GNUNET_Buffer *buf) |
Free the backing memory of the given buffer. More... | |
void GNUNET_buffer_prealloc | ( | struct GNUNET_Buffer * | buf, |
size_t | capacity | ||
) |
Initialize a buffer with the given capacity.
When a buffer is allocated with this function, a warning is logged when the buffer exceeds the initial capacity.
buf | the buffer to initialize |
capacity | the capacity (in bytes) to allocate for buf |
Definition at line 35 of file buffer.c.
References buf, GNUNET_assert, GNUNET_malloc, and GNUNET_YES.
void GNUNET_buffer_ensure_remaining | ( | struct GNUNET_Buffer * | buf, |
size_t | n | ||
) |
Make sure that at least n bytes remaining in the buffer.
buf | buffer to potentially grow |
n | number of bytes that should be available to write |
Definition at line 55 of file buffer.c.
References buf, GNUNET_assert, GNUNET_break, GNUNET_malloc, GNUNET_realloc, and GNUNET_YES.
Referenced by GNUNET_buffer_reap_str(), GNUNET_buffer_write(), GNUNET_buffer_write_data_encoded(), GNUNET_buffer_write_path(), and GNUNET_buffer_write_vfstr().
void GNUNET_buffer_write | ( | struct GNUNET_Buffer * | buf, |
const char * | data, | ||
size_t | len | ||
) |
Write bytes to the buffer.
Grows the buffer if necessary.
buf | buffer to write to |
data | data to read from |
len | number of bytes to copy from data to buf |
Definition at line 86 of file buffer.c.
References buf, data, GNUNET_buffer_ensure_remaining(), and len.
Referenced by GNUNET_buffer_write_path(), GNUNET_buffer_write_str(), GNUNET_STRINGS_urlencode(), and write_to_buffer().
void GNUNET_buffer_write_str | ( | struct GNUNET_Buffer * | buf, |
const char * | str | ||
) |
Write a 0-terminated string to a buffer, excluding the 0-terminator.
Grows the buffer if necessary.
buf | the buffer to write to |
str | the string to write to buf |
buf | the buffer to write to |
str | the string to write to buf |
Definition at line 103 of file buffer.c.
References buf, GNUNET_buffer_write(), and len.
Referenced by GNUNET_CONFIGURATION_serialize_diagnostics(), and login_redirect().
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.
Grows the buffer if necessary.
buf | buffer to write to |
data | data to read from |
data_len | number of bytes to copy from data to buf |
Definition at line 264 of file buffer.c.
References buf, data, GNUNET_assert, GNUNET_buffer_ensure_remaining(), and GNUNET_STRINGS_data_to_string().
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 contents of the buffer and the new string.
buf | buffer to write to |
str | string containing the new path component |
Definition at line 180 of file buffer.c.
References buf, GNUNET_buffer_ensure_remaining(), GNUNET_buffer_write(), and len.
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.
Grows the buffer if necessary.
buf | the buffer to write to |
fmt | format string |
... | format arguments |
Referenced by GNUNET_CONFIGURATION_serialize_diagnostics(), GNUNET_STRINGS_urlencode(), and login_redirect().
void 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.
Grows the buffer if necessary.
buf | the buffer to write to |
fmt | format string |
args | format argument list |
Definition at line 230 of file buffer.c.
References consensus-simulation::args, buf, GNUNET_assert, GNUNET_buffer_ensure_remaining(), and res.
Referenced by GNUNET_buffer_write_fstr().
char* GNUNET_buffer_reap_str | ( | struct GNUNET_Buffer * | buf | ) |
Clear the buffer and return the string it contained.
The caller is responsible to eventually GNUNET_free the returned string.
The returned string is always 0-terminated.
buf | the buffer to reap the string from |
Definition at line 123 of file buffer.c.
References buf, GNUNET_buffer_ensure_remaining(), and res.
Referenced by GNUNET_CONFIGURATION_serialize_diagnostics(), GNUNET_STRINGS_urlencode(), and login_redirect().
void* GNUNET_buffer_reap | ( | struct GNUNET_Buffer * | buf, |
size_t * | size | ||
) |
Clear the buffer and return its contents.
The caller is responsible to eventually GNUNET_free the returned data.
buf | the buffer to reap the contents from |
size | where to store the size of the returned data |
Definition at line 149 of file buffer.c.
References buf, res, and size.
Referenced by GNUNET_BIO_get_buffer_contents().
void GNUNET_buffer_clear | ( | struct GNUNET_Buffer * | buf | ) |
Free the backing memory of the given buffer.
Does not free the memory of the buffer control structure, which is typically stack-allocated.
Definition at line 164 of file buffer.c.
References buf, and GNUNET_free.
Referenced by GNUNET_BIO_write_close(), and GNUNET_STRINGS_urlencode().