* @brief Internal implementation of array_min_element. * * Returns a pointer to the smallest element according to `cmp` * (the first one encountered on ties), or NULL if the array is empty. */
| 280 | * @brief Finds an element in the array for which the predicate returns true. |
| 281 | */ |
| 282 | #define array_find_if(arr, predicate) \ |
| 283 | arrayp_find_if_impl((arr).data, array_size(arr), sizeof((arr).data[0]), (predicate)) |
| 284 | |
| 285 | |
| 286 | /** |
| 287 | * @brief Internal implementation of array_min_element. |
| 288 | * |
| 289 | * Returns a pointer to the smallest element according to `cmp` |
| 290 | * (the first one encountered on ties), or NULL if the array is empty. |
| 291 | */ |
| 292 | static inline void *arrayp_min_element_impl(const void *data, size_t count, size_t elem_size, |
| 293 | int (*cmp)(const void *, const void *)) { |
| 294 | if (count == 0) { |
| 295 | return NULL; |
| 296 | } |
| 297 | unsigned char *ptr = (unsigned char *)(uintptr_t)data; |
| 298 | unsigned char *best = ptr; |
| 299 | for (size_t i = 1; i < count; i++) { |
nothing calls this directly
no outgoing calls
no test coverage detected