annotate osdep/setenv.c @ 24576:6704a924d4aa

According to MSDN a thread must call CoUninitialize once for each successful call it has made to CoInitialize or CoInitializeEx, including any call that returns S_FALSE. Only the CoUninitialize call corresponding to the CoInitialize or CoInitializeEx call that initialized the library can close it. patch by Gianluigi Tiesi, mplayer netfarm it
author diego
date Sun, 23 Sep 2007 20:37:33 +0000
parents 936209c39ed1
children 5cfef41a1771
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17245
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
1 /* setenv implementation for systems lacking it. */
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
2
21853
d0d487227d60 consistent include path
diego
parents: 17245
diff changeset
3 #include "config.h"
17245
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
4
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
5 #include <stdlib.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
6 #include <string.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
7 #ifndef MP_DEBUG
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
8 #define NDEBUG
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
9 #endif
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
10 #include <assert.h>
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
11
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
12 int setenv(const char *name, const char *val, int overwrite)
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
13 {
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
14 int len = strlen(name) + strlen(val) + 2;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
15 char *env = malloc(len);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
16 if (!env) { return -1; }
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
17
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
18 assert(overwrite != 0);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
19
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
20 strcpy(env, name);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
21 strcat(env, "=");
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
22 strcat(env, val);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
23 putenv(env);
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
24
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
25 return 0;
44c24de55f9d - move our setenv() fallback implementation to osdep
al
parents:
diff changeset
26 }