diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util/blob.c | 11 | ||||
-rw-r--r-- | src/util/blob.h | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/util/blob.c b/src/util/blob.c index c89092e1cf3..050df8351f8 100644 --- a/src/util/blob.c +++ b/src/util/blob.c @@ -125,6 +125,17 @@ blob_init_fixed(struct blob *blob, void *data, size_t size) blob->out_of_memory = false; } +void +blob_finish_get_buffer(struct blob *blob, void **buffer, size_t *size) +{ + *buffer = blob->data; + *size = blob->size; + blob->data = NULL; + + /* Trim the buffer. */ + *buffer = realloc(*buffer, *size); +} + bool blob_overwrite_bytes(struct blob *blob, size_t offset, diff --git a/src/util/blob.h b/src/util/blob.h index b56fa4b2fe0..0c275911983 100644 --- a/src/util/blob.h +++ b/src/util/blob.h @@ -117,6 +117,9 @@ blob_finish(struct blob *blob) free(blob->data); } +void +blob_finish_get_buffer(struct blob *blob, void **buffer, size_t *size); + /** * Add some unstructured, fixed-size data to a blob. * |