* @brief Internal implementation of array_max_element. * * Returns a pointer to the largest element according to `cmp` * (the first one encountered on ties), or NULL if the array is empty. */
| 316 | * <0, 0, or >0. |
| 317 | */ |
| 318 | #define array_min_element(arr, cmp) \ |
| 319 | arrayp_min_element_impl((arr).data, array_size(arr), sizeof((arr).data[0]), (cmp)) |
| 320 | |
| 321 | |
| 322 | /** |
| 323 | * @brief Internal implementation of array_max_element. |
| 324 | * |
| 325 | * Returns a pointer to the largest element according to `cmp` |
| 326 | * (the first one encountered on ties), or NULL if the array is empty. |
| 327 | */ |
| 328 | static inline void *arrayp_max_element_impl(const void *data, size_t count, size_t elem_size, |
| 329 | int (*cmp)(const void *, const void *)) { |
| 330 | if (count == 0) { |
| 331 | return NULL; |
| 332 | } |
| 333 | unsigned char *ptr = (unsigned char *)(uintptr_t)data; |
| 334 | unsigned char *best = ptr; |
| 335 | for (size_t i = 1; i < count; i++) { |
nothing calls this directly
no outgoing calls
no test coverage detected