File: outofmem.c

package info (click to toggle)
robotour 3.1.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,596 kB
  • ctags: 2,972
  • sloc: cpp: 17,705; sh: 3,060; ansic: 2,778; makefile: 144
file content (45 lines) | stat: -rwxr-xr-x 934 bytes parent folder | download
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
/* outofmem.c */
#include <stdio.h>
#include "xtdio.h"

/* ---------------------------------------------------------------------- */

/* outofmem: tests if ptr is null.  If it is, the format and arguments
 * a la printf are put to the stdout and then the program exits
 */
#ifdef __PROTOTYPE__
void outofmem(
  void *ptr,
  char *fmt,
  ...)
#else	/* __PROTOTYPE__ */
void outofmem(ptr,fmt,va_alist)
void *ptr;
char *fmt;
va_dcl
#endif	/* __PROTOTYPE__ */
{
va_list args;

/* check if ptr is not null */
if(ptr) return;

#ifdef __PROTOTYPE__
/* initialize for variable arglist handling */
va_start(args,fmt);

#else	/* __PROTOTYPE__ */

/* initialize for variable arglist handling */
va_start(args);

fmt= va_arg(args,char *);
#endif	/* __PROTOTYPE__ */

fprintf(stderr,"***out of memory*** ");
vfprintf(stderr,fmt,args);
va_end(args);
(*error_exit)(1);
}

/* ---------------------------------------------------------------------- */