summaryrefslogtreecommitdiff
path: root/lib/setenv.c
blob: 4f861937f15a50dd3dfc2e206693a6c069807bd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "config.h"

#include <stdlib.h>
#include <string.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;
}