> On Nov 26, 2025, at 14:02, Amul Sul <[email protected]> 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/