File: xmalloc.c

package info (click to toggle)
bass 1.0.7-2
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 988 kB
  • ctags: 721
  • sloc: ansic: 2,545; makefile: 133; sh: 111
file content (45 lines) | stat: -rw-r--r-- 720 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*

xmalloc.c

Author: Liraz Siri <liraz@bigfoot.com>

Copyright (c) 1998 Liraz Siri <liraz@bigfoot.com>, Ariel, Israel,
	      All rights reserved.

Created: Sun Nov  8 20:45:20 IST 1998

stdlib.h memory allocation wrappers.

*/

#include <stdlib.h>
#include "xmalloc.h"
#include "log.h"

void *xmalloc(size_t size)
{
 void *vp;

 if(!(vp = malloc(size)))
  fatal("xmalloc: out of memory, unable to allocate <%ld> bytes", size);

 return vp; 
}

void xfree(void *ptr)
{
 if(!ptr)
  fatal("xfree: trying to free NULL pointer"); 
 free(ptr);
}

void *xrealloc(void *ptr, size_t size)
{
 void *vp;

 if(!(vp = realloc(ptr, size)))
  fatal("xrealloc: out of memory, unable to reallocate <%ld> bytes", size);

 return vp;
}