Re: pg_waldump: support decoding of WAL inside tarfile - Mailing list pgsql-hackers

From Chao Li
Subject Re: pg_waldump: support decoding of WAL inside tarfile
Date
Msg-id 6220A42D-D610-4EC0-97C6-977E6BBC328B@gmail.com
Whole thread Raw
In response to Re: pg_waldump: support decoding of WAL inside tarfile  (Amul Sul <sulamul@gmail.com>)
List pgsql-hackers

> On Nov 26, 2025, at 14:02, Amul Sul <sulamul@gmail.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/







pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: [PATCH] Refactor bytea_sortsupport(), take two
Next
From: Amit Langote
Date:
Subject: Re: transformJsonFuncExpr pathspec cache lookup failed