summaryrefslogtreecommitdiff
path: root/libbcachefs/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/util.h')
-rw-r--r--libbcachefs/util.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/libbcachefs/util.h b/libbcachefs/util.h
index d475f98..cc89da1 100644
--- a/libbcachefs/util.h
+++ b/libbcachefs/util.h
@@ -181,15 +181,19 @@ do { \
} \
} while (0)
-#define heap_add(h, new, cmp) \
+#define __heap_add(h, d, cmp) \
+do { \
+ size_t _i = (h)->used++; \
+ (h)->data[_i] = d; \
+ \
+ heap_sift_up(h, _i, cmp); \
+} while (0)
+
+#define heap_add(h, d, cmp) \
({ \
bool _r = !heap_full(h); \
- if (_r) { \
- size_t _i = (h)->used++; \
- (h)->data[_i] = new; \
- \
- heap_sift_up(h, _i, cmp); \
- } \
+ if (_r) \
+ __heap_add(h, d, cmp); \
_r; \
})