File: xmalloc.c

package info (click to toggle)
lookup 1.08b-5
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 1,108 kB
  • ctags: 1,305
  • sloc: ansic: 12,634; makefile: 236; perl: 174; sh: 53
file content (18 lines) | stat: -rw-r--r-- 308 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "xmalloc.h"

#undef xmalloc

/*
 * like malloc(), but dies if memory not available.
 */
void *xmalloc(unsigned len)
{
    void *ptr;
    if (ptr = (void *)malloc(len), ptr == 0)
    {
        #define MSG "<out of memory in malloc>\n"
	write(2, MSG, sizeof(MSG)-1);
	exit(3);
    }
    return ptr;
}