Print this page
XXXX update sendmail to 8.14.9
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/sendmail/include/sm/rpool.h
+++ new/usr/src/cmd/sendmail/include/sm/rpool.h
1 1 /*
2 - * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers.
2 + * Copyright (c) 2000-2001, 2003 Proofpoint, Inc. and its suppliers.
3 3 * All rights reserved.
4 4 *
5 5 * By using this file, you agree to the terms and conditions set
6 6 * forth in the LICENSE file which can be found at the top level of
7 7 * the sendmail distribution.
8 8 *
9 - * $Id: rpool.h,v 1.16 2003/09/05 23:07:49 ca Exp $
9 + * $Id: rpool.h,v 1.17 2013-11-22 20:51:31 ca Exp $
10 10 */
11 11
12 -#pragma ident "%Z%%M% %I% %E% SMI"
13 -
14 12 /*
15 13 ** libsm resource pools
16 14 ** See libsm/rpool.html for documentation.
17 15 */
18 16
19 17 #ifndef SM_RPOOL_H
20 18 # define SM_RPOOL_H
21 19
22 20 # include <sm/gen.h>
23 21 # include <sm/heap.h>
24 22 # include <sm/string.h>
25 23
26 24 /*
27 25 ** Each memory pool object consists of an SM_POOLLINK_T,
28 26 ** followed by a platform specific amount of padding,
29 27 ** followed by 'poolsize' bytes of pool data,
30 28 ** where 'poolsize' is the value of rpool->sm_poolsize at the time
31 29 ** the pool is allocated.
32 30 */
33 31
34 32 typedef struct sm_poollink SM_POOLLINK_T;
35 33 struct sm_poollink
36 34 {
37 35 SM_POOLLINK_T *sm_pnext;
38 36 };
39 37
40 38 typedef void (*SM_RPOOL_RFREE_T) __P((void *_rcontext));
41 39
42 40 typedef SM_RPOOL_RFREE_T *SM_RPOOL_ATTACH_T;
43 41
44 42 typedef struct sm_resource SM_RESOURCE_T;
45 43 struct sm_resource
46 44 {
47 45 /*
48 46 ** Function for freeing this resource. It may be NULL,
49 47 ** meaning that this resource has already been freed.
50 48 */
51 49
52 50 SM_RPOOL_RFREE_T sm_rfree;
53 51 void *sm_rcontext; /* resource data */
54 52 };
55 53
56 54 # define SM_RLIST_MAX 511
57 55
58 56 typedef struct sm_rlist SM_RLIST_T;
59 57 struct sm_rlist
60 58 {
61 59 SM_RESOURCE_T sm_rvec[SM_RLIST_MAX];
62 60 SM_RLIST_T *sm_rnext;
63 61 };
64 62
65 63 typedef struct
66 64 {
67 65 /* Points to SmRpoolMagic, or is NULL if rpool is freed. */
68 66 const char *sm_magic;
69 67
70 68 /*
71 69 ** If this rpool object has no parent, then sm_parentlink
72 70 ** is NULL. Otherwise, we set *sm_parentlink = NULL
73 71 ** when this rpool is freed, so that it isn't freed a
74 72 ** second time when the parent is freed.
75 73 */
76 74
77 75 SM_RPOOL_RFREE_T *sm_parentlink;
78 76
79 77 /*
80 78 ** Memory pools
81 79 */
82 80
83 81 /* Size of the next pool to be allocated, not including the header. */
84 82 size_t sm_poolsize;
85 83
86 84 /*
87 85 ** If an sm_rpool_malloc_x request is too big to fit
88 86 ** in the current pool, and the request size > bigobjectsize,
89 87 ** then the object will be given its own malloc'ed block.
90 88 ** sm_bigobjectsize <= sm_poolsize. The maximum wasted space
91 89 ** at the end of a pool is maxpooledobjectsize - 1.
92 90 */
93 91
94 92 size_t sm_bigobjectsize;
95 93
96 94 /* Points to next free byte in the current pool. */
97 95 char *sm_poolptr;
98 96
99 97 /*
100 98 ** Number of bytes available in the current pool.
101 99 ** Initially 0. Set to 0 by sm_rpool_free.
102 100 */
103 101
104 102 size_t sm_poolavail;
105 103
106 104 /* Linked list of memory pools. Initially NULL. */
107 105 SM_POOLLINK_T *sm_pools;
108 106
109 107 /*
110 108 ** Resource lists
111 109 */
112 110
113 111 SM_RESOURCE_T *sm_rptr; /* Points to next free resource slot. */
114 112
115 113 /*
116 114 ** Number of available resource slots in current list.
117 115 ** Initially 0. Set to 0 by sm_rpool_free.
118 116 */
119 117
120 118 size_t sm_ravail;
121 119
122 120 /* Linked list of resource lists. Initially NULL. */
123 121 SM_RLIST_T *sm_rlists;
124 122
125 123 #if _FFR_PERF_RPOOL
126 124 int sm_nbigblocks;
127 125 int sm_npools;
128 126 #endif /* _FFR_PERF_RPOOL */
129 127
130 128 } SM_RPOOL_T;
131 129
132 130 extern SM_RPOOL_T *
133 131 sm_rpool_new_x __P((
134 132 SM_RPOOL_T *_parent));
135 133
136 134 extern void
137 135 sm_rpool_free __P((
138 136 SM_RPOOL_T *_rpool));
139 137
140 138 # if SM_HEAP_CHECK
141 139 extern void *
142 140 sm_rpool_malloc_tagged_x __P((
143 141 SM_RPOOL_T *_rpool,
144 142 size_t _size,
145 143 char *_file,
146 144 int _line,
147 145 int _group));
148 146 # define sm_rpool_malloc_x(rpool, size) \
149 147 sm_rpool_malloc_tagged_x(rpool, size, __FILE__, __LINE__, SmHeapGroup)
150 148 extern void *
151 149 sm_rpool_malloc_tagged __P((
152 150 SM_RPOOL_T *_rpool,
153 151 size_t _size,
154 152 char *_file,
155 153 int _line,
156 154 int _group));
157 155 # define sm_rpool_malloc(rpool, size) \
158 156 sm_rpool_malloc_tagged(rpool, size, __FILE__, __LINE__, SmHeapGroup)
159 157 # else /* SM_HEAP_CHECK */
160 158 extern void *
161 159 sm_rpool_malloc_x __P((
162 160 SM_RPOOL_T *_rpool,
163 161 size_t _size));
164 162 extern void *
165 163 sm_rpool_malloc __P((
166 164 SM_RPOOL_T *_rpool,
167 165 size_t _size));
168 166 # endif /* SM_HEAP_CHECK */
169 167
170 168 #if DO_NOT_USE_STRCPY
171 169 extern char *sm_rpool_strdup_x __P((SM_RPOOL_T *rpool, const char *s));
172 170 #else /* DO_NOT_USE_STRCPY */
173 171 # define sm_rpool_strdup_x(rpool, str) \
174 172 strcpy(sm_rpool_malloc_x(rpool, strlen(str) + 1), str)
175 173 #endif /* DO_NOT_USE_STRCPY */
176 174
177 175 extern SM_RPOOL_ATTACH_T
178 176 sm_rpool_attach_x __P((
179 177 SM_RPOOL_T *_rpool,
180 178 SM_RPOOL_RFREE_T _rfree,
181 179 void *_rcontext));
182 180
183 181 # define sm_rpool_detach(a) ((void)(*(a) = NULL))
184 182
185 183 extern void
186 184 sm_rpool_setsizes __P((
187 185 SM_RPOOL_T *_rpool,
188 186 size_t _poolsize,
189 187 size_t _bigobjectsize));
190 188
191 189 #endif /* ! SM_RPOOL_H */
|
↓ open down ↓ |
168 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX