Add a comment that explains why this header has no multiple inclusion guards.
[mplayer/greg.git] / osdep / setenv.c
blob1dd6c4828ee5f8edb1c2f9d0cd8816913f90f591
1 /* setenv implementation for systems lacking it. */
3 #include "config.h"
5 #include <stdlib.h>
6 #include <string.h>
7 #ifndef MP_DEBUG
8 #define NDEBUG
9 #endif
10 #include <assert.h>
12 int setenv(const char *name, const char *val, int overwrite)
14 int len = strlen(name) + strlen(val) + 2;
15 char *env = malloc(len);
16 if (!env) { return -1; }
18 assert(overwrite != 0);
20 strcpy(env, name);
21 strcat(env, "=");
22 strcat(env, val);
23 putenv(env);
25 return 0;