diff options
author | drh <> | 2025-05-30 15:43:04 +0000 |
---|---|---|
committer | drh <> | 2025-05-30 15:43:04 +0000 |
commit | 8ae57fab64aa1e16596763b9d9435aa1f7e9933d (patch) | |
tree | 08f48e7b32ea63b4a1884af32452e5be6c222e2f /src | |
parent | b65326f51a2c8c9fcb5331cde36d55aa7d209a27 (diff) | |
download | sqlite-8ae57fab64aa1e16596763b9d9435aa1f7e9933d.tar.gz sqlite-8ae57fab64aa1e16596763b9d9435aa1f7e9933d.zip |
Use a more robust backup definition for offsetof().
FossilOrigin-Name: 22441955e03df07903b98832a60c05c53721cd67c667f6c83d5e97fcc62735ee
Diffstat (limited to 'src')
-rw-r--r-- | src/sqliteInt.h | 9 | ||||
-rw-r--r-- | src/vdbeInt.h | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index af7ed4a4c..994a3864c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -765,7 +765,7 @@ ** ourselves. */ #ifndef offsetof -#define offsetof(STRUCTURE,FIELD) ((size_t)((char*)&((STRUCTURE*)0)->FIELD)) +# define offsetof(ST,M) ((size_t)((char*)&((ST*)0)->M - (char*)0)) #endif /* @@ -2661,6 +2661,13 @@ struct KeyInfo { /* The size (in bytes) of a KeyInfo object with up to N fields */ #define SZ_KEYINFO(N) (offsetof(KeyInfo,aColl) + (N)*sizeof(CollSeq*)) +/* The size of a bare KeyInfo with no aColl[] entries */ +#if FLEXARRAY+1 > 1 +# define SZ_KEYINFO_0 offsetof(KeyInfo,aColl) +#else +# define SZ_KEYINFO_0 sizeof(KeyInfo) +#endif + /* ** Allowed bit values for entries in the KeyInfo.aSortFlags[] array. */ diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 13262cd4e..0faa32747 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -557,7 +557,7 @@ struct PreUpdate { Table *pTab; /* Schema object being updated */ Index *pPk; /* PK index if pTab is WITHOUT ROWID */ sqlite3_value **apDflt; /* Array of default values, if required */ - u8 keyinfoSpace[SZ_KEYINFO(0)]; /* Space to hold pKeyinfo[0] content */ + u8 keyinfoSpace[SZ_KEYINFO_0]; /* Space to hold pKeyinfo[0] content */ }; /* |