#include <unistd.h>
#include <malloc.h>
#include <stdarg.h>
#include <stdio.h>

void *xmalloc(size_t size)
{
#define MESSAGE "Out of memory.\n"
  void *res;
  res = malloc(size);
  if (res == (void*)0 && size != 0)
    {
      write(2, MESSAGE, sizeof(MESSAGE));
/*      printf("Out of memory.\n"); */
      exit(1);
    }
  return res;
}

void fatal(int val, const char *message, ...)
{
 va_list param;
 va_start(param,message);
 vfprintf(stderr,message,param);
 va_end(param);
 if (val)
   exit(1);
}