Skip to content

Commit b1fdc72

Browse files
committed
Fix Windows build broken in 6943a94
Also it fixes dynamic array allocation disallowed by ANSI-C. Author: Stas Kelvich
1 parent 8829af4 commit b1fdc72

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/utils/adt/tsvector_op.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef struct
6666
#define STATHDRSIZE (offsetof(TSVectorStat, data))
6767

6868
static Datum tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column);
69-
static int tsvector_bsearch(TSVector tsin, char *lexin, int lexin_len);
69+
static int tsvector_bsearch(const TSVector tsv, char *lexeme, int lexeme_len);
7070

7171
/*
7272
* Order: haspos, len, word, for all positions (pos, weight)
@@ -684,10 +684,12 @@ tsvector_to_array(PG_FUNCTION_ARGS)
684684
{
685685
TSVector tsin = PG_GETARG_TSVECTOR(0);
686686
WordEntry *arrin = ARRPTR(tsin);
687-
Datum elements[tsin->size];
687+
Datum *elements;
688688
int i;
689689
ArrayType *array;
690690

691+
elements = palloc(tsin->size * sizeof(Datum));
692+
691693
for (i = 0; i < tsin->size; i++)
692694
{
693695
elements[i] = PointerGetDatum(
@@ -696,6 +698,8 @@ tsvector_to_array(PG_FUNCTION_ARGS)
696698
}
697699

698700
array = construct_array(elements, tsin->size, TEXTOID, -1, false, 'i');
701+
702+
pfree(elements);
699703
PG_FREE_IF_COPY(tsin, 0);
700704
PG_RETURN_POINTER(array);
701705
}

0 commit comments

Comments
 (0)