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
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* misc.h - Just the subset of defs needed for opqcp.
*
* Author: Russ Fish
* Computer Science Dept.
* University of Utah
* Date: 1 August 1980
*/
#ifndef MISCH /* Only once. */
#define MISCH
#include <stdio.h> /* Defines NULL. */
/*****************************************************************
* TAGS( string boolean fn byte address )
*
* Commonly used types.
*
*/
typedef char * string; /* Character Strings. */
typedef int boolean; /* Logical vars or values. */
typedef char byte; /* Byte is the unit of "sizeof". */
typedef char * address;
/*****************************************************************
* TAGS( TRUE FALSE )
*/
#define TRUE 1 /* Logical constants. */
#define FALSE 0
/*****************************************************************
* TAGS( NEW NEW_1 NEW_N new )
*
* NEW(type,size)
* Generalized allocation function, given an object type and size (in
* bytes) to be allocated.
*
* Variants:
* NEW_1(type) - Allocate a single object of the given type.
* NEW_N(type,n) - Allocate an array of N objects of the given type.
*/
extern address
new(); /* In-core allocator. */
/* ( size )
* int size;
*/
#define NEW(type,size) (type *)new(size) /* Macro with type cast. */
#define NEW_1(type) (type *)new(sizeof(type)) /* Single arg, fixed size. */
#define NEW_N(type,n) (type *)new((n)*sizeof(type)) /* Array of base type. */
/*****************************************************************
* TAGS( FREE free dispose )
*
* Macros to cast the argument to dispose().
*/
#define FREE( ptr ) dispose( (address)ptr )
#define free( ptr ) dispose( (address)ptr )
/*****************************************************************
* TAG( SIZE SIZE_N msize )
*
* SIZE returns the size (in bytes) of an allocated object.
*
* SIZE_N returns the number of objects of TYPE in ARRAY.
*/
extern long
msize();
/* ( obj )
* address obj;
*/
#define SIZE(obj) msize( (address)obj )
#define SIZE_N(type, array) (msize( (address)array ) / sizeof (type))
#endif