]> git.ipfire.org Git - thirdparty/dhcp.git/blob - includes/omapip/alloc.h
copy rights update
[thirdparty/dhcp.git] / includes / omapip / alloc.h
1 /* alloc.h
2
3 Definitions for the object management API protocol memory allocation... */
4
5 /*
6 * Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
8 *
9 * This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 *
21 * Internet Systems Consortium, Inc.
22 * PO Box 360
23 * Newmarket, NH 03857 USA
24 * <info@isc.org>
25 * https://www.isc.org/
26 *
27 */
28
29 isc_result_t omapi_buffer_new (omapi_buffer_t **, const char *, int);
30 isc_result_t omapi_buffer_reference (omapi_buffer_t **,
31 omapi_buffer_t *, const char *, int);
32 isc_result_t omapi_buffer_dereference (omapi_buffer_t **, const char *, int);
33
34 #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
35 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
36 #define DMDOFFSET (sizeof (struct dmalloc_preamble))
37 #define DMLFSIZE 16
38 #define DMUFSIZE 16
39 #define DMDSIZE (DMDOFFSET + DMLFSIZE + DMUFSIZE)
40
41 struct dmalloc_preamble {
42 struct dmalloc_preamble *prev, *next;
43 const char *file;
44 int line;
45 size_t size;
46 unsigned long generation;
47 unsigned char low_fence [DMLFSIZE];
48 };
49 #else
50 #define DMDOFFSET 0
51 #define DMDSIZE 0
52 #endif
53
54 /* rc_history flags... */
55 #define RC_LEASE 1
56 #define RC_MISC 2
57
58 #if defined (DEBUG_RC_HISTORY)
59 #if !defined (RC_HISTORY_MAX)
60 # define RC_HISTORY_MAX 256
61 #endif
62
63 #if !defined (RC_HISTORY_FLAGS)
64 # define RC_HISTORY_FLAGS (RC_LEASE | RC_MISC)
65 #endif
66
67 struct rc_history_entry {
68 const char *file;
69 int line;
70 void *reference;
71 void *addr;
72 int refcnt;
73 };
74
75 #define rc_register(x, l, r, y, z, d, f) do { \
76 if (RC_HISTORY_FLAGS & ~(f)) { \
77 rc_history [rc_history_index].file = (x); \
78 rc_history [rc_history_index].line = (l); \
79 rc_history [rc_history_index].reference = (r); \
80 rc_history [rc_history_index].addr = (y); \
81 rc_history [rc_history_index].refcnt = (z); \
82 rc_history_next (d); \
83 } \
84 } while (0)
85 #define rc_register_mdl(r, y, z, d, f) \
86 rc_register (__FILE__, __LINE__, r, y, z, d, f)
87 #else
88 #define rc_register(file, line, reference, addr, refcnt, d, f)
89 #define rc_register_mdl(reference, addr, refcnt, d, f)
90 #endif
91
92 #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
93 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
94 extern struct dmalloc_preamble *dmalloc_list;
95 extern unsigned long dmalloc_outstanding;
96 extern unsigned long dmalloc_longterm;
97 extern unsigned long dmalloc_generation;
98 extern unsigned long dmalloc_cutoff_generation;
99 #endif
100
101 #if defined (DEBUG_RC_HISTORY)
102 extern struct rc_history_entry rc_history [RC_HISTORY_MAX];
103 extern int rc_history_index;
104 extern int rc_history_count;
105 #endif