blob: 1dd6c4828ee5f8edb1c2f9d0cd8816913f90f591 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* setenv implementation for systems lacking it. */
#include "config.h"
#include <stdlib.h>
#include <string.h>
#ifndef MP_DEBUG
#define NDEBUG
#endif
#include <assert.h>
int setenv(const char *name, const char *val, int overwrite)
{
int len = strlen(name) + strlen(val) + 2;
char *env = malloc(len);
if (!env) { return -1; }
assert(overwrite != 0);
strcpy(env, name);
strcat(env, "=");
strcat(env, val);
putenv(env);
return 0;
}
|