view osdep/setenv.c @ 22045:2e1b3754ca2d

Bugfix: glyph and bitmap pointers could be left uninitialized after get_glyph(). Based on a patch by Stanislav Maslovski (stanislav d maslovski a gmail d com).
author eugeni
date Mon, 29 Jan 2007 17:08:29 +0000
parents 936209c39ed1
children 5cfef41a1771
line wrap: on
line source

/* setenv implementation for systems lacking it. */

#include "config.h"

#include <stdlib.h>
#include <string.h>
#ifndef MP_DEBUG
  #define NDEBUG
#endif
#include <assert.h>

int setenv(const char *name, const char *val, int overwrite)
{
  int len  = strlen(name) + strlen(val) + 2;
  char *env = malloc(len);
  if (!env) { return -1; }

  assert(overwrite != 0);

  strcpy(env, name);
  strcat(env, "=");
  strcat(env, val);
  putenv(env);

  return 0;
}