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

Function algorithm_fill

algorithm/algorithm.c:746–754  ·  view source on GitHub ↗

* @brief Fills a range with a specified value. * * @param first Pointer to the start of the range. * @param last Pointer to the end of the range. * @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

744 const char *ae = b - sz;
745 const char *be = b + (n - 1) * sz;
746 char *oe = out + (2 * n - 1) * sz;
747 for (size_t k = 0; k < n; ++k) {
748 int f = comp(b, a) < 0; /* front: b strictly smaller -> b */
749 int g = comp(be, ae) < 0; /* back: be strictly smaller -> ae is the largest */
750 alg_copy_elem(out, f ? b : a, sz);
751 alg_copy_elem(oe, g ? ae : be, sz);
752 out += sz;
753 oe -= sz;
754 b += f ? sz : 0;
755 a += f ? 0 : sz;
756 ae -= g ? sz : 0;
757 be -= g ? 0 : sz;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected