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.
The following table shows the palloced size [(slen / 2 + 1) *3] and the
actual trgm count for different string length.
slen palloc size actual trgm count
2 6 3
26 42 27
38 60 39
Can somebody please explain this to me.
I had tried changing the allocation to slen + 1 and it seemed to be working
without any problem.
trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen + 1));
Maybe I am missisng some scenarios.
Any help would be appreciated.
Thank you,
Beena Emerson
-----
--
Beena Emerson
--
View this message in context: http://postgresql.nabble.com/pg-trgm-Memory-Allocation-logic-tp5841088.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.