diff options
author | Connor Abbott <[email protected]> | 2017-09-15 00:29:46 -0400 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-10-12 21:47:06 -0700 |
commit | 6935440967e2beccf017c96e75387b9cb71833b4 (patch) | |
tree | c9eedb5e27a9be9e4d6d4d1c3ca250afd0cbfb55 /src/compiler/glsl | |
parent | 8ae03af4ed1ca47a106e5fd7b2d11ce4003aad54 (diff) |
compiler/blob: make blob_reserve_bytes() more useful
Despite the name, it could only be used if you immediately wrote to the
pointer. Noboby was using it outside of one test, so clearly this
behavior wasn't that useful. Instead, make it return an offset into the
data buffer so that the result isn't invalidated if you later write to
the blob. In conjunction with blob_overwrite_bytes(), this will be
useful for leaving a placeholder and then filling it in later, which
we'll need to do for handling phi nodes when serializing NIR.
v2 (Jason Ekstrand):
- Detect overflow in the offset + to_write computation
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r-- | src/compiler/glsl/tests/blob_test.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/compiler/glsl/tests/blob_test.c b/src/compiler/glsl/tests/blob_test.c index d49f4a02cf9..0b4955b6b68 100644 --- a/src/compiler/glsl/tests/blob_test.c +++ b/src/compiler/glsl/tests/blob_test.c @@ -120,7 +120,7 @@ test_write_and_read_functions (void) { struct blob blob; struct blob_reader reader; - uint8_t *reserved; + ssize_t reserved; size_t str_offset, uint_offset; uint8_t reserve_buf[sizeof(reserve_test_str)]; @@ -131,7 +131,7 @@ test_write_and_read_functions (void) blob_write_bytes(&blob, bytes_test_str, sizeof(bytes_test_str)); reserved = blob_reserve_bytes(&blob, sizeof(reserve_test_str)); - memcpy(reserved, reserve_test_str, sizeof(reserve_test_str)); + blob_overwrite_bytes(&blob, reserved, reserve_test_str, sizeof(reserve_test_str)); /* Write a placeholder, (to be replaced later via overwrite_bytes) */ str_offset = blob.size; |