Trivial Fix: use palloc_array/repalloc_array for BufFile file arrays

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Trivial Fix: use palloc_array/repalloc_array for BufFile file arrays
Date: 2025-12-25 03:12:07
Message-ID: CAEoWx2m1Vo97Jg9=K7JAZ0xdkg5D=GkgOxZR1=EW7mUfy008fw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

I noticed this error while working on [1].

In BufFile, the fields is claimed as an array:
```
struct BufFile
{
File *files; /* palloc'd array with numFiles entries */
```

However, it’s allocated by palloc_object():
```
file->files = palloc_object(File);
```

And reallocated by repalloc():
```
file->files = (File *) repalloc(file->files,
(file->numFiles + 1) * sizeof(File));
```

This trivial patch just changes to use palloc_array/repalloc_array, which
makes the intent clearer.

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

Attachment Content-Type Size
v1-0001-Use-palloc_array-repalloc_array-for-BufFile-file-.patch application/octet-stream 2.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-12-25 03:14:19 RE: doc: update the default of data checksums in the doc of pg_rewind
Previous Message Zshengbin91 2025-12-25 03:05:15 improve comments on CreateFunction returnsSet