Mesa (master): util: add blob_finish_get_buffer

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Nov 8 20:33:23 UTC 2019


Module: Mesa
Branch: master
Commit: ad56022b0d96ca6a823623dd93b3f0bf9de17ba8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ad56022b0d96ca6a823623dd93b3f0bf9de17ba8

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Thu Nov  7 19:10:55 2019 -0500

util: add blob_finish_get_buffer

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/util/blob.c | 11 +++++++++++
 src/util/blob.h |  3 +++
 2 files changed, 14 insertions(+)

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.
  *




More information about the mesa-commit mailing list