MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / __array_reduce_impl

Function __array_reduce_impl

array/array.h:401–421  ·  view source on GitHub ↗

* @brief Internal implementation of array_reduce. * * Reduces the array to a single value by applying a binary reduction * function. `result` must be large enough to hold one element. */

Source from the content-addressed store, hash-verified

399/**
400 * @brief Transforms each element of the source array and stores the
401 * result in the destination array. Both arrays must be of the
402 * same type and size.
403 */
404#define array_transform(src, dest, func) \
405 arrayp_transform_impl((src).data, (dest).data, array_size(src), sizeof((src).data[0]), (func))
406
407
408/**
409 * @brief Internal implementation of array_reduce.
410 *
411 * Reduces the array to a single value by applying a binary reduction
412 * function. `result` must be large enough to hold one element.
413 */
414static inline void arrayp_reduce_impl(const void *data, size_t count, size_t elem_size,
415 void *result,
416 void (*reduce_func)(const void *, const void *, void *)) {
417 if (count == 0) {
418 return;
419 }
420 memcpy(result, data, elem_size);
421 const unsigned char *ptr = (const unsigned char *)data;
422
423 unsigned char stackbuf[256];
424 unsigned char *temp = (elem_size <= sizeof(stackbuf)) ? stackbuf

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected