Re: use the malloc macros in pg_dump.c

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: use the malloc macros in pg_dump.c
Date: 2026-02-13 08:22:38
Message-ID: aY7fTmLKI1x93AmH@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 13, 2026 at 06:06:26PM +1100, Peter Smith wrote:
> At the same time, I combined all previous patches.

That's a practice better than sending a handful bag of patches that
each touch one single file. :)

Seems globally clean to me, except for two changes.

- zp = gzipcs->zp = (z_streamp) pg_malloc(sizeof(z_stream));
+ zp = gzipcs->zp = (z_streamp) pg_malloc_object(z_stream);
[...]
- zp = (z_streamp) pg_malloc(sizeof(z_stream));
+ zp = (z_streamp) pg_malloc_object(z_stream);

These two defeat the purpose of the change. _object is useful because
we can enforce type checks based on their size. Note that We have
this declaration in zlib:
zlib.h:typedef z_stream FAR *z_streamp;

So we should be OK with dropping the casts entirely, with I guess
compilers not warning if types do not match as an effect of this
typedef declaration. I have removed these, and things seem OK here,
now to say if the buildfarm is entirely OK will be a different thing.
I'll see about that if/once required.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-02-13 08:24:30 Re: Our ABI diff infrastructure ignores enum SysCacheIdentifier
Previous Message Bertrand Drouvot 2026-02-13 08:03:04 Re: PGPROC alignment (was Re: pgsql: Separate RecoveryConflictReasons from procsignals)