Mercurial > mplayer.hg
comparison osdep/setenv.c @ 17245:44c24de55f9d
- move our setenv() fallback implementation to osdep
- assert that the override param is nonzero (zero is not implemented)
- correct return value type to int
based on a patch by Diego
fixes bugzilla bug #342
author | al |
---|---|
date | Mon, 26 Dec 2005 03:16:48 +0000 |
parents | |
children | d0d487227d60 |
comparison
equal
deleted
inserted
replaced
17244:70120627f0b9 | 17245:44c24de55f9d |
---|---|
1 /* setenv implementation for systems lacking it. */ | |
2 | |
3 #include "../config.h" | |
4 | |
5 #ifndef HAVE_SETENV | |
6 | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #ifndef MP_DEBUG | |
10 #define NDEBUG | |
11 #endif | |
12 #include <assert.h> | |
13 | |
14 int setenv(const char *name, const char *val, int overwrite) | |
15 { | |
16 int len = strlen(name) + strlen(val) + 2; | |
17 char *env = malloc(len); | |
18 if (!env) { return -1; } | |
19 | |
20 assert(overwrite != 0); | |
21 | |
22 strcpy(env, name); | |
23 strcat(env, "="); | |
24 strcat(env, val); | |
25 putenv(env); | |
26 | |
27 return 0; | |
28 } | |
29 #endif |