-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathalloc.h
More file actions
85 lines (67 loc) · 2.23 KB
/
alloc.h
File metadata and controls
85 lines (67 loc) · 2.23 KB
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
79
80
81
82
83
#ifndef ALLOC_H
#define ALLOC_H
/*
* This work was supported by the United States Government, and is
* not subject to copyright.
*
* $Log: memory.h,v $
* Revision 1.5 1997/01/21 19:17:11 dar
* made C++ compatible
*
* Revision 1.4 1993/10/15 18:49:23 libes
* CADDETC certified
*
* Revision 1.3 1993/02/22 21:41:13 libes
* ANSI compat
*
* Revision 1.2 1992/08/18 17:15:40 libes
* rm'd extraneous error messages
*
* Revision 1.1 1992/05/28 03:56:02 libes
* Initial revision
*/
#include "basic.h"
/*****************/
/* packages used */
/*****************/
#include <sc_export.h>
/** \file alloc.h - defs for fixed size block memory allocator */
typedef long Align;
union freelist {
union freelist * next; /**< next block on freelist */
char memory; /**< user data */
Align aligner; /**< force alignment of blocks */
};
typedef union freelist Freelist;
struct freelist_head {
int size_elt; /**< size of a single elt */
#ifndef NOSTAT
int alloc; /**< # of allocations */
int dealloc;
int create; /**< number of calls to create a new freelist */
void *max; /**< end of freelist */
#endif
int size; /**< size of a single elt incl. next ptr */
int bytes; /**< if we run out, allocate memory by this many bytes */
Freelist * freelist;
#ifdef SPACE_PROFILE
int count;
#endif
};
char * nnew(void);
#include "error.h"
/***********************************************/
/* space allocation macros with error package: */
/***********************************************/
extern SC_EXPRESS_EXPORT int yylineno;
/** CALLOC grabs and initializes to all 0s space for the indicated
* number of instances of the indicated type */
#define CALLOC(ptr, num, type) \
if (((ptr) = (type*)calloc((num), (unsigned)sizeof(type)))==NULL) { \
fprintf(stderr,"fedex: out of space");\
} else {}
SC_EXPRESS_EXPORT void _ALLOCinitialize( void );
SC_EXPRESS_EXPORT void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 );
SC_EXPRESS_EXPORT void ALLOC_destroy( struct freelist_head *, Freelist * );
SC_EXPRESS_EXPORT void * ALLOC_new( struct freelist_head * );
#endif /* ALLOC_H */