Re: pg_waldump: support decoding of WAL inside tarfile

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_waldump: support decoding of WAL inside tarfile
Date: 2025-11-26 07:23:39
Message-ID: 6220A42D-D610-4EC0-97C6-977E6BBC328B@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Nov 26, 2025, at 14:02, Amul Sul <sulamul(at)gmail(dot)com> wrote:
>
>> 9 - 0004
>> ```
>> +/*
>> + * Create an astreamer that can read WAL from tar file.
>> + */
>> +static astreamer *
>> +astreamer_waldump_new(XLogDumpPrivate *privateInfo)
>> +{
>> + astreamer_waldump *streamer;
>> +
>> + streamer = palloc0(sizeof(astreamer_waldump));
>> + *((const astreamer_ops **) &streamer->base.bbs_ops) =
>> + &astreamer_waldump_ops;
>> +
>> + streamer->privateInfo = privateInfo;
>> +
>> + return &streamer->base;
>> +}
>> ```
>>
>> This function allocates memory for streamer but only returns &streamer->base, so memory of streamer is leaked.
>>
>
> May I know why you think there would be a memory leak? I believe the
> address of the structure is the same as the address of its first
> member, base. I am returning base because the goal is to return a
> generic astreamer type, which is the standard approach used in other
> archive streamer code.

Ah… Got it.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2025-11-26 07:32:20 Re: transformJsonFuncExpr pathspec cache lookup failed
Previous Message John Naylor 2025-11-26 07:18:52 Re: [PATCH] Refactor bytea_sortsupport(), take two