diff options
Diffstat (limited to 'lib/setenv.c')
-rw-r--r-- | lib/setenv.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/setenv.c b/lib/setenv.c new file mode 100644 index 000000000..8087bd661 --- /dev/null +++ b/lib/setenv.c @@ -0,0 +1,21 @@ +#include "config.h" + +#include <stdlib.h> +#include <string.h> +#include <malloc.h> +#include <stdio.h> + +/* This function will leak a small amount of memory */ +int _xine_private_setenv(const char *name, const char *val) { + int len; + char *env; + + len = strlen(name) + strlen(val) + 2; + env = malloc(len); + if (env != NULL) { + snprintf(env, len, "%s=%s", name, val); + putenv(env); + return 0; + } else return -1; +} + |