Fix Windows build broken in 6943a946c7

Also it fixes dynamic array allocation disallowed by ANSI-C.

Author: Stas Kelvich
This commit is contained in:
Teodor Sigaev 2016-03-11 20:10:20 +03:00
parent 8829af47ef
commit b1fdc727c3
1 changed files with 6 additions and 2 deletions

View File

@ -66,7 +66,7 @@ typedef struct
#define STATHDRSIZE (offsetof(TSVectorStat, data))
static Datum tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column);
static int tsvector_bsearch(TSVector tsin, char *lexin, int lexin_len);
static int tsvector_bsearch(const TSVector tsv, char *lexeme, int lexeme_len);
/*
* Order: haspos, len, word, for all positions (pos, weight)
@ -684,10 +684,12 @@ tsvector_to_array(PG_FUNCTION_ARGS)
{
TSVector tsin = PG_GETARG_TSVECTOR(0);
WordEntry *arrin = ARRPTR(tsin);
Datum elements[tsin->size];
Datum *elements;
int i;
ArrayType *array;
elements = palloc(tsin->size * sizeof(Datum));
for (i = 0; i < tsin->size; i++)
{
elements[i] = PointerGetDatum(
@ -696,6 +698,8 @@ tsvector_to_array(PG_FUNCTION_ARGS)
}
array = construct_array(elements, tsin->size, TEXTOID, -1, false, 'i');
pfree(elements);
PG_FREE_IF_COPY(tsin, 0);
PG_RETURN_POINTER(array);
}