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

Function algorithm_fill_n

algorithm/algorithm.c:764–772  ·  view source on GitHub ↗

* @brief Fills the first n elements of a range with a specified value. * * @param first Pointer to the start of the range. * @param n Number of elements to fill. * @param size Size of each element in bytes. * @param val Pointer to the value to fill the range with. */

Source from the content-addressed store, hash-verified

762 * (a2 | a2 + n) -> o2 in lockstep: four independent comparison chains. */
763ALG_INLINE void stb_parity_merge2(const char *a1, const char *a2, size_t n, char *o1, char *o2,
764 size_t sz, AlgorithmCompareFunc comp) {
765 const char *b1 = a1 + n * sz, *ae1 = b1 - sz, *be1 = b1 + (n - 1) * sz;
766 const char *b2 = a2 + n * sz, *ae2 = b2 - sz, *be2 = b2 + (n - 1) * sz;
767 char *oe1 = o1 + (2 * n - 1) * sz, *oe2 = o2 + (2 * n - 1) * sz;
768 for (size_t k = 0; k < n; ++k) {
769 int f1 = comp(b1, a1) < 0;
770 int f2 = comp(b2, a2) < 0;
771 int g1 = comp(be1, ae1) < 0;
772 int g2 = comp(be2, ae2) < 0;
773 alg_copy_elem(o1, f1 ? b1 : a1, sz);
774 alg_copy_elem(o2, f2 ? b2 : a2, sz);
775 alg_copy_elem(oe1, g1 ? ae1 : be1, sz);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected