Re: Fix and improve allocation formulas
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-12-18T04:47:01Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
btree_gist: Fix memory allocation formula
- 5cf03552fbb4 19 (unreleased) landed
On Wed, Dec 17, 2025 at 09:24:31AM +0000, Bertrand Drouvot wrote: > I'd vote for just changing the palloc() like proposed in v1. It does not seem that bad if we treat the uint8 rule for actual bytes, but I'm going to leave that for others to comment for now. By the way, while checking again the whole, David has proposed something different for btree_utils_var.c still a bit incorrect: https://www.postgresql.org/message-id/4ab4a12b-49e9-4ebf-9055-225c8055fed0@gmail.com I had my eyes on it a couple of days ago and noticed the bytea vs GBT_VARKEY business, but discarded it to look at the rest first because there were a lot of patterns to look at. His solution used palloc_array(), with a "bytea *". Okay, that's actually the same as btree_utils_var.h tells that bytea and GBT_VARKEY are the same thing, but there is also a point in being consistent in the code with what the header wants. So I have reused the palloc_array() with GBT_VARKEY, meaning that the solution of 5cf03552fbb4 is a mix of what both of you have proposed, except that it's consistent with the declaration. -- Michael