MT#61368 add function to merge to bencode buffers

Change-Id: I1c5d28b6e241c60f5c71c7e5f04845a082182778
pull/1897/head
Richard Fuchs 1 year ago
parent 73ec8df939
commit 733e232892

@ -146,6 +146,12 @@ void bencode_buffer_free(bencode_buffer_t *buf) {
}
}
void bencode_buffer_merge(bencode_buffer_t *to, bencode_buffer_t *from) {
from->pieces->next = to->pieces;
to->pieces = from->pieces;
from->pieces = NULL;
}
static bencode_item_t *__bencode_item_alloc(bencode_buffer_t *buf, size_t payload) {
bencode_item_t *ret;

@ -69,6 +69,9 @@ void *bencode_buffer_alloc(bencode_buffer_t *, size_t);
* and all objects created through it become invalid. */
void bencode_buffer_free(bencode_buffer_t *buf);
// Move all objects from one buffer to another. The `from` buffer will be unusable afterwards.
void bencode_buffer_merge(bencode_buffer_t *to, bencode_buffer_t *from);
/* Creates a new empty dictionary object. Memory will be allocated from the bencode_buffer_t object.
* Returns NULL if no memory could be allocated. */
bencode_item_t *bencode_dictionary(bencode_buffer_t *buf);

Loading…
Cancel
Save