From 27db2b71452dca0ae92d099966f7bebe596c056c Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 30 Mar 2024 23:52:33 -0700 Subject: [PATCH] Align values [skip ci] --- src/sparsevec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sparsevec.h b/src/sparsevec.h index c822c65..4a658f2 100644 --- a/src/sparsevec.h +++ b/src/sparsevec.h @@ -3,8 +3,8 @@ #define SPARSEVEC_MAX_DIM 100000 -#define SPARSEVEC_SIZE(_nnz) (offsetof(SparseVector, indices) + (_nnz) * sizeof(int32) + (_nnz * sizeof(float))) -#define SPARSEVEC_VALUES(x) ((float *) (((char *) (x)) + offsetof(SparseVector, indices) + (x)->nnz * sizeof(int32))) +#define SPARSEVEC_SIZE(_nnz) (offsetof(SparseVector, indices) + MAXALIGN((_nnz) * sizeof(int32)) + (_nnz * sizeof(float))) +#define SPARSEVEC_VALUES(x) ((float *) (((char *) (x)) + offsetof(SparseVector, indices) + MAXALIGN((x)->nnz * sizeof(int32)))) #define DatumGetSparseVector(x) ((SparseVector *) PG_DETOAST_DATUM(x)) #define PG_GETARG_SPARSEVEC_P(x) DatumGetSparseVector(PG_GETARG_DATUM(x)) #define PG_RETURN_SPARSEVEC_P(x) PG_RETURN_POINTER(x)