| #include "../git-compat-util.h" |
| int gitsetenv(const char *name, const char *value, int replace) |
| size_t namelen, valuelen; |
| if (!name || strchr(name, '=') || !value) { |
| valuelen = strlen(value); |
| envstr = malloc(st_add3(namelen, valuelen, 2)); |
| memcpy(envstr, name, namelen); |
| memcpy(envstr + namelen + 1, value, valuelen); |
| envstr[namelen + valuelen + 1] = 0; |
| /* putenv(3) makes the argument string part of the environment, |
| * and changing that string modifies the environment --- which |
| * means we do not own that storage anymore. Do not free |