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

Function cbm_memmem

internal/cbm/helpers.c:33–48  ·  view source on GitHub ↗

Hand-rolled memmem: does not rely on the system memmem (GNU/BSD-only; msys2-clang on Windows lacks it), so it compiles identically everywhere.

Source from the content-addressed store, hash-verified

31// Hand-rolled memmem: does not rely on the system memmem (GNU/BSD-only;
32// msys2-clang on Windows lacks it), so it compiles identically everywhere.
33void *cbm_memmem(const void *haystack, size_t haystack_len, const void *needle, size_t needle_len) {
34 if (needle_len == 0) {
35 return (void *)haystack;
36 }
37 if (needle_len > haystack_len) {
38 return NULL;
39 }
40 const char *h = (const char *)haystack;
41 size_t last = haystack_len - needle_len;
42 for (size_t i = 0; i <= last; i++) {
43 if (memcmp(h + i, needle, needle_len) == 0) {
44 return (void *)(h + i);
45 }
46 }
47 return NULL;
48}
49
50// --- Node text extraction ---
51

Callers 3

kotlin_eval_expr_typeFunction · 0.85
kt_apply_smart_castFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected