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

Function cbm_git_child_envp

src/foundation/git_env.c:147–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145#else
146
147char **cbm_git_child_envp(void) {
148 size_t count = 0;
149 size_t bytes = 0;
150 for (char **e = environ; e && *e; e++) {
151 if (!cbm_git_env_entry_should_strip(*e)) {
152 count++;
153 bytes += strlen(*e) + 1;
154 }
155 }
156 size_t table = (count + 1) * sizeof(char *);
157 char **envp = (char **)cbm_alloc(CBM_MEM_CLASS_OTHER, table + bytes);
158 if (!envp) {
159 return NULL;
160 }
161 char *strings = (char *)envp + table;
162 size_t slot = 0;
163 for (char **e = environ; e && *e && slot < count; e++) {
164 if (!cbm_git_env_entry_should_strip(*e)) {
165 size_t len = strlen(*e) + 1;
166 memcpy(strings, *e, len);
167 envp[slot++] = strings;
168 strings += len;
169 }
170 }
171 envp[slot] = NULL;
172 return envp;
173}
174
175#endif
176

Callers 2

cbm_subprocess_copy_optsFunction · 0.85
cbm_popen_gitFunction · 0.85

Calls 2

cbm_allocFunction · 0.85

Tested by

no test coverage detected