summaryrefslogtreecommitdiff
path: root/lib/setenv.c
blob: 8087bd661eb04e2cc49348e9af7cedd7901c0858 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
}