[PATCH 2/8] lib min_heap: Add typedef for sift_down function pointer

Kuan-Wei Chiu <[email protected]>
Newsgroups org.kernel.vger.linux-bcache,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
Several min-heap operations such as min_heapify_all(), min_heap_pop(),
min_heap_pop_push(), and min_heap_del() use min_heap_sift_down()
internally. With the addition of the equal-elements-aware variant
min_heap_sift_down_eqaware(), these functions now need to choose
between multiple sift_down implementations.

Introduce a siftdown_fn_t typedef to represent the function pointer
type for sift_down routines. This avoids repeating verbose function
pointer declarations and simplifies code that dynamically selects the
appropriate implementation based on heap characteristics.

Cc: [email protected] # 6.11+
Signed-off-by: Kuan-Wei Chiu <[email protected]>
---
 include/linux/min_heap.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/min_heap.h b/include/linux/min_heap.h
index b0d603fe5379..4cd8fd9db259 100644
--- a/include/linux/min_heap.h
+++ b/include/linux/min_heap.h
@@ -49,6 +49,9 @@ struct min_heap_callbacks {
 	void (*swp)(void *lhs, void *rhs, void *args);
 };
 
+typedef void (*siftdown_fn_t)(min_heap_char *heap, size_t pos, size_t elem_size,
+			    const struct min_heap_callbacks *func, void *args);
+
 /**
  * is_aligned - is this pointer & size okay for word-wide copying?
  * @base: pointer to data
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.