MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / dm_repeated

Function dm_repeated

tests/test_doc_mentions.c:5968–5982  ·  view source on GitHub ↗

`prefix`, then `unit` n times, then `suffix`; the caller frees it. */

Source from the content-addressed store, hash-verified

5966
5967/* `prefix`, then `unit` n times, then `suffix`; the caller frees it. */
5968static char *dm_repeated(const char *prefix, const char *unit, int n, const char *suffix) {
5969 size_t pl = strlen(prefix);
5970 size_t ul = strlen(unit);
5971 size_t sl = strlen(suffix);
5972 char *out = malloc(pl + (ul * (size_t)n) + sl + 1);
5973 if (!out) {
5974 return NULL;
5975 }
5976 memcpy(out, prefix, pl);
5977 for (int i = 0; i < n; i++) {
5978 memcpy(out + pl + (ul * (size_t)i), unit, ul);
5979 }
5980 memcpy(out + pl + (ul * (size_t)n), suffix, sl + 1);
5981 return out;
5982}
5983
5984typedef struct {
5985 char *src;

Callers 2

dm_cost_growthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected