On 16.05.22 10:27, Peter Eisentraut wrote:
Inspired by [0], I looked to convert more macros to inline functions.

Here is another one from the same batch of work that I somehow didn't send in last time.

(IMO it's questionable whether this one should be an inline function or macro at all, rather than a normal external function.)
From 6d1e97d8d03e2a01842dacd3528bf2dbf40377cf Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Tue, 19 Jul 2022 06:58:12 +0200
Subject: [PATCH] Convert macros to static inline functions (rel.h)

---
 src/include/utils/rel.h | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 7dc401cf0df9..aee07a6979b1 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -572,22 +572,23 @@ RelationGetSmgr(Relation rel)
                smgrsetowner(&(rel->rd_smgr), smgropen(rel->rd_locator, 
rel->rd_backend));
        return rel->rd_smgr;
 }
-#endif
 
 /*
  * RelationCloseSmgr
  *             Close the relation at the smgr level, if not already done.
- *
- * Note: smgrclose should unhook from owner pointer, hence the Assert.
  */
-#define RelationCloseSmgr(relation) \
-       do { \
-               if ((relation)->rd_smgr != NULL) \
-               { \
-                       smgrclose((relation)->rd_smgr); \
-                       Assert((relation)->rd_smgr == NULL); \
-               } \
-       } while (0)
+static inline void
+RelationCloseSmgr(Relation relation)
+{
+       if (relation->rd_smgr != NULL)
+       {
+               smgrclose(relation->rd_smgr);
+
+               /* smgrclose should unhook from owner pointer */
+               Assert(relation->rd_smgr == NULL);
+       }
+}
+#endif
 
 /*
  * RelationGetTargetBlock
-- 
2.37.3

Reply via email to