-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncs.c
63 lines (49 loc) · 1.34 KB
/
funcs.c
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*- FUNCS.C ----------------------------------------------------------------*/
/*- terminate the program reporting an error -------------------------------*/
#include "structs.h"
#include "bsp.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
void ProgError(const char *errstr, ...)
{
va_list args;
va_start( args, errstr);
fprintf(stderr, "\nProgram Error: *** ");
vfprintf( stderr, errstr, args);
fprintf(stderr, " ***\n");
va_end( args);
#ifdef HAVE_UNLINK
if (unlinkwad) unlink(unlinkwad);
#endif
exit( 5);
}
/* Print stuff if verbose output */
int verbosity;
void Verbose(const char *errstr, ...)
{
va_list args;
if (!verbosity) return;
va_start( args, errstr);
vprintf(errstr, args);
va_end( args);
}
#ifndef WITH_DMALLOC
/*- allocate memory with error checking ------------------------------------*/
void* GetMemory(size_t size)
{
void *ret = malloc( size);
if (!ret)
ProgError( "out of memory (cannot allocate %zu bytes)", size);
return ret;
}
/*- reallocate memory with error checking ----------------------------------*/
void* ResizeMemory(void *old, size_t size)
{
void *ret = realloc( old, size);
if (!ret)
ProgError( "out of memory (cannot reallocate %zu bytes)", size);
return ret;
}
#endif
/*--------------------------------------------------------------------------*/