File: xmalloc.c

package info (click to toggle)
lookup 1.08b-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 1,112 kB
  • ctags: 1,306
  • sloc: ansic: 12,638; makefile: 245; perl: 174; sh: 53
file content (19 lines) | stat: -rw-r--r-- 313 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "xmalloc.h"

#include <stdio.h>
#include <stdlib.h>

/*
 * like malloc(), but dies if memory not available.
 */
void *xmalloc(unsigned int len)
{
    void *ptr;
    ptr = malloc(len);
    if (ptr == NULL)
    {
      fprintf(stderr, "<out of memory in malloc>\n");
      exit(3);
    }
    return ptr;
}