diff options
author | Alessio Vanni <vannilla@firemail.cc> | 2020-05-14 16:03:10 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-05-19 02:41:47 +0200 |
commit | f4771fcc1c3fda21a46d0cb85d8b29e012254696 (patch) | |
tree | 012df74ed2cf44cb20605b239e1b88dab6edc645 /src/include/gnunet_buffer_lib.h | |
parent | 6a52ce5f9bc35a852b215e7073f3a0d2665ca8de (diff) | |
download | gnunet-f4771fcc1c3fda21a46d0cb85d8b29e012254696.tar.gz gnunet-f4771fcc1c3fda21a46d0cb85d8b29e012254696.zip |
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 <christian@grothoff.org>
Diffstat (limited to 'src/include/gnunet_buffer_lib.h')
-rw-r--r-- | src/include/gnunet_buffer_lib.h | 13 |
1 files changed, 13 insertions, 0 deletions
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 | |||
@@ -165,6 +165,19 @@ GNUNET_buffer_reap_str (struct GNUNET_Buffer *buf); | |||
165 | 165 | ||
166 | 166 | ||
167 | /** | 167 | /** |
168 | * Clear the buffer and return its contents. | ||
169 | * The caller is responsible to eventually #GNUNET_free | ||
170 | * the returned data. | ||
171 | * | ||
172 | * @param buf the buffer to reap the contents from | ||
173 | * @param size where to store the size of the returned data | ||
174 | * @returns the data contained in the string | ||
175 | */ | ||
176 | void * | ||
177 | GNUNET_buffer_reap (struct GNUNET_Buffer *buf, size_t *size); | ||
178 | |||
179 | |||
180 | /** | ||
168 | * Free the backing memory of the given buffer. | 181 | * Free the backing memory of the given buffer. |
169 | * Does not free the memory of the buffer control structure, | 182 | * Does not free the memory of the buffer control structure, |
170 | * which is typically stack-allocated. | 183 | * which is typically stack-allocated. |