Teodor Sigaev <teodor(at)sigaev(dot)ru> writes:
> I suggest to replace bytea by struct
> typedef struct {
> int32 n; /* number of GISTENTRY */
> GISTENTRY vector[1];
> } GistEntryVector;
Yes, I was thinking the same thing.
> #define GEVHDRSZ (MAXALIGN(sizeof(int32))
> so, allocation will be:
> evec = palloc( GEVHDRSZ + sizeof(GISTENTRY)*n );
> MAXALIGN guarantee that allocated memory will be no less than required (it may
> be greater for 4 bytes).
That would work, or you could use offsetof(GistEntryVector, vector[0]).
regards, tom lane