blob: e0ef9a35bcde74bc16dd03dc7c3b4ece05915041 (
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
27
28
29
|
/* setenv implementation for systems lacking it. */
#include "../config.h"
#ifndef HAVE_SETENV
#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;
}
#endif
|