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

Function algorithm_generate_n

algorithm/algorithm.c:1271–1282  ·  view source on GitHub ↗

* @brief Generates values for the first n elements of a range using a generator function. * * @param first Pointer to the start of the range. * @param n Number of elements to generate. * @param size Size of each element in bytes. * @param gen Generator function that produces values. */

Source from the content-addressed store, hash-verified

1269 }
1270
1271 const char *ptr1 = (const char*)base1;
1272 const char *ptr2 = (const char*)base2;
1273
1274 /* from the last possible start backwards: the first hit is the answer */
1275 for (size_t i = num1 - num2 + 1; i-- > 0; ) {
1276 size_t j = 0;
1277 while (j < num2 && comp(ptr1 + (i + j) * size1, ptr2 + j * size2) == 0) {
1278 ++j;
1279 }
1280 if (j == num2) {
1281 ALGORITHM_LOG("[algorithm_find_end] Info: Subsequence found starting at index %zu.", i);
1282 return (void *)(ptr1 + i * size1);
1283 }
1284 }
1285

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected