}
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;
}
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;
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)
* 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;
};
* 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
*
* \return The bytes read (see note above about memory lifetime).
*/
-void *
+const void *
blob_read_bytes(struct blob_reader *blob, size_t size);
/**
}
static void
-expect_equal_bytes(uint8_t *expected, uint8_t *actual,
+expect_equal_bytes(uint8_t *expected, const uint8_t *actual,
size_t num_bytes, const char *test)
{
size_t i;