Beena Emerson <memissemerson(at)gmail(dot)com> writes:
> In the pg_trgm module, within function generate_trgm, the memory for trigrams
> is allocated as follows:
> trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) *3);
> I have been trying to understand why this is so because it seems to be
> allocating more space than that is required.
Consider input like 'X X X X X'. Each X produces 3 trigrams.
regards, tom lane