MCPcopy Create free account
hub / github.com/USBGuard/usbguard / createExecutableEnvironment

Method createExecutableEnvironment

src/CLI/IPCSignalWatcher.cpp:272–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270 }
271
272 char** IPCSignalWatcher::createExecutableEnvironment(const std::map<std::string, std::string>& environment)
273 {
274 size_t environ_size = 0;
275
276 if (environ != nullptr) {
277 for (char** global_envp = environ; global_envp[0] != nullptr; ++global_envp) {
278 ++environ_size;
279 }
280 }
281
282 char** envp = new char* [environ_size + environment.size() + 1];
283 size_t i = 0;
284
285 for (; i < environ_size; ++i) {
286 envp[i] = cstrCopy(environ[i]);
287 }
288
289 for (const auto& map_entry : environment) {
290 std::string environ_value;
291 environ_value.append(map_entry.first);
292 environ_value.append("=");
293 environ_value.append(map_entry.second);
294 envp[i++] = cstrCopy(environ_value.c_str());
295 }
296
297 envp[i] = nullptr;
298 return envp;
299 }
300
301 void IPCSignalWatcher::destroyExecutableEnvironment(char** const envp)
302 {

Callers

nothing calls this directly

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected