Debian Codegraph @

COSMIC/outofmem.c

raw
1 /* outofmem.c */
2 #include <stdio.h>
3 #include "sockets.h"
4
5 /* ---------------------------------------------------------------------- */
6
7 /* outofmem: tests if ptr is null. If it is, the format and arguments
8 * a la printf are put to the stdout and then the program exits
9 */
10 #ifdef __PROTOTYPE__
11 void outofmem(
12 void *ptr,
13 char *fmt,
14 ...)
15 #else /* __PROTOTYPE__ */
16 void outofmem(ptr,fmt,va_alist)
17 void *ptr;
18 char *fmt;
19 va_dcl
20 #endif /* __PROTOTYPE__ */
21 {
22 va_list args;
23
24 /* check if ptr is not null */
25 if(ptr) return;
26
27 #ifdef __PROTOTYPE__
28 /* initialize for variable arglist handling */
29 va_start(args,fmt);
30
31 #else /* __PROTOTYPE__ */
32
33 /* initialize for variable arglist handling */
34 va_start(args);
35
36 fmt= va_arg(args,char *);
37 #endif /* __PROTOTYPE__ */
38
39 fprintf(stderr,"***out of memory*** ");
40 vfprintf(stderr,fmt,args);
41 va_end(args);
42 (*error_exit)(1);
43 }
44
45 /* ---------------------------------------------------------------------- */