File: setenv.c

package info (click to toggle)
xine-lib 1.1.19-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 44,660 kB
  • ctags: 77,375
  • sloc: ansic: 521,588; sh: 11,336; asm: 3,649; makefile: 2,836; objc: 828; pascal: 530; awk: 234; perl: 97; sed: 16
file content (20 lines) | stat: -rw-r--r-- 402 bytes parent folder | download | duplicates (11)
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;
}