From ecbe0a41f7d799c3c6a5b8545fc20f180273ee2d Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Tue, 3 Feb 2026 10:32:54 +1100
Subject: [PATCH v2] modify malloc for parallel.c

---
 src/bin/pg_dump/parallel.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index ddaf08faa30..56cb2c1f32d 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -469,7 +469,7 @@ WaitForTerminatingWorkers(ParallelState *pstate)
 		}
 #else							/* WIN32 */
 		/* On Windows, we must use WaitForMultipleObjects() */
-		HANDLE	   *lpHandles = pg_malloc(sizeof(HANDLE) * pstate->numWorkers);
+		HANDLE	   *lpHandles = pg_malloc_array(HANDLE, pstate->numWorkers);
 		int			nrun = 0;
 		DWORD		ret;
 		uintptr_t	hThread;
@@ -903,7 +903,7 @@ ParallelBackupStart(ArchiveHandle *AH)
 
 	Assert(AH->public.numWorkers > 0);
 
-	pstate = (ParallelState *) pg_malloc(sizeof(ParallelState));
+	pstate = pg_malloc_object(ParallelState);
 
 	pstate->numWorkers = AH->public.numWorkers;
 	pstate->te = NULL;
@@ -913,10 +913,10 @@ ParallelBackupStart(ArchiveHandle *AH)
 		return pstate;
 
 	/* Create status arrays, being sure to initialize all fields to 0 */
-	pstate->te = (TocEntry **)
-		pg_malloc0(pstate->numWorkers * sizeof(TocEntry *));
-	pstate->parallelSlot = (ParallelSlot *)
-		pg_malloc0(pstate->numWorkers * sizeof(ParallelSlot));
+	pstate->te =
+		pg_malloc0_array(TocEntry *, pstate->numWorkers);
+	pstate->parallelSlot =
+		pg_malloc0_array(ParallelSlot, pstate->numWorkers);
 
 #ifdef WIN32
 	/* Make fmtId() and fmtQualifiedId() use thread-local storage */
@@ -969,7 +969,7 @@ ParallelBackupStart(ArchiveHandle *AH)
 
 #ifdef WIN32
 		/* Create transient structure to pass args to worker function */
-		wi = (WorkerInfo *) pg_malloc(sizeof(WorkerInfo));
+		wi = pg_malloc_object(WorkerInfo);
 
 		wi->AH = AH;
 		wi->slot = slot;
-- 
2.47.3

