[Mesa-dev] [PATCH 07/11] compiler/blob: Constify the reader

Jason Ekstrand jason at jlekstrand.net
Wed Oct 11 20:38:47 UTC 2017


---
 src/compiler/blob.c | 10 +++++-----
 src/compiler/blob.h | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/compiler/blob.c b/src/compiler/blob.c
index c5ed9f5..4ebe94b 100644
--- a/src/compiler/blob.c
+++ b/src/compiler/blob.c
@@ -236,10 +236,10 @@ blob_write_string(struct blob *blob, const char *str)
 }
 
 void
-blob_reader_init(struct blob_reader *blob, uint8_t *data, size_t size)
+blob_reader_init(struct blob_reader *blob, const uint8_t *data, size_t size)
 {
    blob->data = data;
-   blob->end = data + size;
+   blob->end = blob->data + size;
    blob->current = data;
    blob->overrun = false;
 }
@@ -262,10 +262,10 @@ ensure_can_read(struct blob_reader *blob, size_t size)
    return false;
 }
 
-void *
+const void *
 blob_read_bytes(struct blob_reader *blob, size_t size)
 {
-   void *ret;
+   const void *ret;
 
    if (! ensure_can_read (blob, size))
       return NULL;
@@ -280,7 +280,7 @@ blob_read_bytes(struct blob_reader *blob, size_t size)
 void
 blob_copy_bytes(struct blob_reader *blob, uint8_t *dest, size_t size)
 {
-   uint8_t *bytes;
+   const uint8_t *bytes;
 
    bytes = blob_read_bytes(blob, size);
    if (bytes == NULL)
diff --git a/src/compiler/blob.h b/src/compiler/blob.h
index ad4b6fa..547d49b 100644
--- a/src/compiler/blob.h
+++ b/src/compiler/blob.h
@@ -78,9 +78,9 @@ struct blob {
  *   2. blob->overrun should be false, (otherwise, too much was read).
  */
 struct blob_reader {
-   uint8_t *data;
-   uint8_t *end;
-   uint8_t *current;
+   const uint8_t *data;
+   const uint8_t *end;
+   const uint8_t *current;
    bool overrun;
 };
 
@@ -269,7 +269,7 @@ blob_write_string(struct blob *blob, const char *str);
  * current value is unchanged before and after the call.
  */
 void
-blob_reader_init(struct blob_reader *blob, uint8_t *data, size_t size);
+blob_reader_init(struct blob_reader *blob, const uint8_t *data, size_t size);
 
 /**
  * Read some unstructured, fixed-size data from the current location, (and
@@ -281,7 +281,7 @@ blob_reader_init(struct blob_reader *blob, uint8_t *data, size_t size);
  *
  * \return The bytes read (see note above about memory lifetime).
  */
-void *
+const void *
 blob_read_bytes(struct blob_reader *blob, size_t size);
 
 /**
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list