-
Notifications
You must be signed in to change notification settings - Fork 2
/
Alloc.h
65 lines (52 loc) · 2.23 KB
/
Alloc.h
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
63
64
65
/*
* Alloc.h - memory allocation module header
*
* DESCRIPTION
* This header contains macros that replace the standard C memory
* allocation routines. They throw an exception when there is not
* enough memory. The macros use functions defined in "Alloc.c".
* The handy new() macro is added; it only needs the type name.
*
* Using macros allows the file name and line number information supplied
* by the preprocessor, to be available for error reporting.
*
* COPYRIGHT
* You are free to use, copy or modify this software at your own risk.
*
* AUTHOR
* Cornelis van der Bent. Please let me know if you have comments or find
* flaws: [email protected]. Enjoy!
*
* MODIFICATION HISTORY
* 1999/04/12 vdbent Thorough test and debugging; beta release.
* 1998/12/18 vdbent Conception.
*/
#ifndef _ALLOC_H
#define _ALLOC_H
#include <stdlib.h>
#include "Except.h"
#define new(type) AllocCalloc(pC, 1, sizeof(type), __FILE__, __LINE__)
#define calloc(n, size) AllocCalloc(pC, n, size, __FILE__, __LINE__)
#define malloc(size) AllocMalloc(pC, size, __FILE__, __LINE__)
#define realloc(p,size) AllocRealloc(pC, p, size, __FILE__, __LINE__)
extern
void * AllocCalloc(
Context * pC, /* pointer to thread exception context */
int number, /* number of elements */
int size, /* size of one element */
char * file, /* name of source file where invoked */
int line); /* source file line number */
extern
void * AllocMalloc(
Context * pC, /* pointer to thread exception context */
int size, /* size of one element */
char * file, /* name of source file where invoked */
int line); /* source file line number */
extern
void * AllocRealloc(
Context * pC, /* pointer to thread exception context */
void * p, /* pointer to original block */
int size, /* size of one element */
char * file, /* name of source file where invoked */
int line); /* source file line number */
#endif /* _ALLOC_H */