From 4ef3b82b91eaee132cfed886f6a1a1455bb084a3 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Mon, 29 Dec 2025 11:41:35 +0900
Subject: [PATCH v14 2/3] Add MultiXactOffsetStorageSize()

This calculates the amount of space taken by two multixact offsets,
useful on its own to know the amount of space multixacts may use.  This
will be used by an upcoming patch.
---
 src/include/access/multixact_internal.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/include/access/multixact_internal.h b/src/include/access/multixact_internal.h
index f2d6539e8a67..65dc2be148db 100644
--- a/src/include/access/multixact_internal.h
+++ b/src/include/access/multixact_internal.h
@@ -121,4 +121,14 @@ MXOffsetToMemberOffset(MultiXactOffset offset)
 		member_in_group * sizeof(TransactionId);
 }
 
+/* Storage space consumed by a range of offsets, in bytes */
+static inline int64
+MultiXactOffsetStorageSize(MultiXactOffset new_offset,
+						   MultiXactOffset old_offset)
+{
+	Assert(new_offset >= old_offset);
+	return (int64) ((new_offset - old_offset) / MULTIXACT_MEMBERS_PER_MEMBERGROUP) *
+		   MULTIXACT_MEMBERGROUP_SIZE;
+}
+
 #endif							/* MULTIXACT_INTERNAL_H */
-- 
2.51.0

