From f4771fcc1c3fda21a46d0cb85d8b29e012254696 Mon Sep 17 00:00:00 2001 From: Alessio Vanni Date: Thu, 14 May 2020 16:03:10 +0200 Subject: Improved BIO API BIO now supports reading from and writing to in-memory buffers. For reading, an allocated buffer (array) and a size is passed as arguments to the function opening the handle. For writing, a GNUNET_Buffer is created and used internally. The buffer contents can be extracted using the relevant function. There is a new API in addition to the existing read/write: this new API is more "declarative" in nature and is meant to mimic APIs like GNUNET_SQ. The read/write operations are defined in an array of specs which are then "commited" in a single (non-atomic) operation, rather than explicitly executing multiple function calls and checking their return value. Also there are small changes to GNUNET_Buffer to account for BIO's new features. Signed-off-by: Christian Grothoff --- src/include/gnunet_buffer_lib.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/include/gnunet_buffer_lib.h') diff --git a/src/include/gnunet_buffer_lib.h b/src/include/gnunet_buffer_lib.h index c0ae06d77..e23536ab2 100644 --- a/src/include/gnunet_buffer_lib.h +++ b/src/include/gnunet_buffer_lib.h @@ -164,6 +164,19 @@ char * GNUNET_buffer_reap_str (struct GNUNET_Buffer *buf); +/** + * Clear the buffer and return its contents. + * The caller is responsible to eventually #GNUNET_free + * the returned data. + * + * @param buf the buffer to reap the contents from + * @param size where to store the size of the returned data + * @returns the data contained in the string + */ +void * +GNUNET_buffer_reap (struct GNUNET_Buffer *buf, size_t *size); + + /** * Free the backing memory of the given buffer. * Does not free the memory of the buffer control structure, -- cgit v1.2.3