Re: Add malloc attribute to memory allocation functions
solai v <solai.cdac@gmail.com>
From: solai v <solai.cdac@gmail.com>
To: Tristan Partin <tristan@partin.io>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-07-06T03:54:25Z
Lists: pgsql-hackers
Hi Tristan, I tested this patch on the current master branch. Before applying the patch, I checked that functions like palloc(), MemoryContextAlloc(), and pstrdup() were not annotated with a malloc attribute. After applying the patch, I verified that pg_attribute_malloc is added in src/include/c.h and that the relevant backend and frontend memory allocation functions are annotated appropriately. I also confirmed that functions intended to be freed with pfree() use pg_attribute_malloc(pfree), while the frontend allocation functions use pg_attribute_malloc(pg_free). The patch applied cleanly, PostgreSQL built successfully, and make check completed successfully with all 245 tests passing. I didn't notice any regressions during testing. Thanks for working on this patch. Regards, Solai