mirror of https://github.com/bjornbytes/lovr.git
Fix temporary vector memory layout;
It's important that the bits for the vector type occupy the least significant bits, so that vectors can be distinguished from pointer lightuserdata. When the vector pool was expanded, this broke, causing e.g. Blob pointers to exhibit undefined behavior when trying to use them as vectors. tbh I still don't understand the union/bitfield memory layout.
This commit is contained in:
parent
d109518c27
commit
c5afb32ad2
|
@ -46,9 +46,9 @@ typedef enum {
|
||||||
typedef union {
|
typedef union {
|
||||||
void* pointer;
|
void* pointer;
|
||||||
struct {
|
struct {
|
||||||
unsigned index : 24;
|
|
||||||
unsigned type : 4;
|
unsigned type : 4;
|
||||||
unsigned generation : 4;
|
unsigned generation : 4;
|
||||||
|
unsigned index : 24;
|
||||||
unsigned padding : 32;
|
unsigned padding : 32;
|
||||||
} handle;
|
} handle;
|
||||||
} Vector;
|
} Vector;
|
||||||
|
|
Loading…
Reference in New Issue