10000 Simplify lists for IvfflatScanOpaque [skip ci] · postgrespro/pgvector@e1bc929 · GitHub
[go: up one dir, main page]

Skip to content

Commit e1bc929

Browse files
committed
Simplify lists for IvfflatScanOpaque [skip ci]
1 parent 38285aa commit e1bc929

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/ivfflat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ typedef struct IvfflatScanOpaqueData
278278
pairingheap *listQueue;
279279
BlockNumber *listPages;
280280
int listIndex;
281-
IvfflatScanList lists[FLEXIBLE_ARRAY_MEMBER]; /* must come last */
281+
IvfflatScanList *lists;
282282
} IvfflatScanOpaqueData;
283283

284284
typedef IvfflatScanOpaqueData * IvfflatScanOpaque;

src/ivfscan.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
280280
if (maxProbes > lists)
281281
maxProbes = lists;
282282

283-
so = (IvfflatScanOpaque) palloc(offsetof(IvfflatScanOpaqueData, lists) + maxProbes * sizeof(IvfflatScanList));
283+
so = (IvfflatScanOpaque) palloc(sizeof(IvfflatScanOpaqueData));
284284
so->typeInfo = IvfflatGetTypeInfo(index);
285285
so->first = true;
286286
so->probes = probes;
@@ -314,6 +314,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
314314
so->listQueue = pairingheap_allocate(CompareLists, scan);
315315
so->listPages = palloc(maxProbes * sizeof(BlockNumber));
316316
so->listIndex = 0;
317+
so->lists = palloc(maxProbes * sizeof(IvfflatScanList));
317318

318319
scan->opaque = so;
319320

@@ -409,6 +410,7 @@ ivfflatendscan(IndexScanDesc scan)
409410
tuplesort_end(so->sortstate);
410411
FreeAccessStrategy(so->bas);
411412
FreeTupleDesc(so->tupdesc);
413+
pfree(so->lists);
412414

413415
/* TODO Free vslot and mslot without freeing TupleDesc */
414416

0 commit comments

Comments
 (0)
0