]>
Commit | Line | Data |
---|---|---|
a40cbc2b TL |
1 | /* alloc.h |
2 | ||
3 | Definitions for the object management API protocol memory allocation... */ | |
4 | ||
5 | /* | |
7512d88b | 6 | * Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC") |
98311e4b | 7 | * Copyright (c) 1996-2003 by Internet Software Consortium |
a40cbc2b | 8 | * |
7512d88b TM |
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/. | |
a40cbc2b | 12 | * |
98311e4b DH |
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. | |
a40cbc2b | 20 | * |
98311e4b DH |
21 | * Internet Systems Consortium, Inc. |
22 | * 950 Charter Street | |
23 | * Redwood City, CA 94063 | |
24 | * <info@isc.org> | |
2c85ac9b | 25 | * https://www.isc.org/ |
49733f31 | 26 | * |
a40cbc2b TL |
27 | */ |
28 | ||
4bd8800e | 29 | isc_result_t omapi_buffer_new (omapi_buffer_t **, const char *, int); |
a40cbc2b | 30 | isc_result_t omapi_buffer_reference (omapi_buffer_t **, |
4bd8800e TL |
31 | omapi_buffer_t *, const char *, int); |
32 | isc_result_t omapi_buffer_dereference (omapi_buffer_t **, const char *, int); | |
33 | ||
d758ad8c TL |
34 | #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ |
35 | defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) | |
4bd8800e TL |
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 | ||
98311e4b DH |
54 | /* rc_history flags... */ |
55 | #define RC_LEASE 1 | |
56 | #define RC_MISC 2 | |
57 | ||
4bd8800e TL |
58 | #if defined (DEBUG_RC_HISTORY) |
59 | #if !defined (RC_HISTORY_MAX) | |
60 | # define RC_HISTORY_MAX 256 | |
61 | #endif | |
62 | ||
98311e4b DH |
63 | #if !defined (RC_HISTORY_FLAGS) |
64 | # define RC_HISTORY_FLAGS (RC_LEASE | RC_MISC) | |
65 | #endif | |
66 | ||
4bd8800e TL |
67 | struct rc_history_entry { |
68 | const char *file; | |
69 | int line; | |
bc7b98ab TL |
70 | void *reference; |
71 | void *addr; | |
4bd8800e TL |
72 | int refcnt; |
73 | }; | |
74 | ||
98311e4b DH |
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 | } \ | |
4bd8800e | 84 | } while (0) |
98311e4b DH |
85 | #define rc_register_mdl(r, y, z, d, f) \ |
86 | rc_register (__FILE__, __LINE__, r, y, z, d, f) | |
4bd8800e | 87 | #else |
98311e4b DH |
88 | #define rc_register(file, line, reference, addr, refcnt, d, f) |
89 | #define rc_register_mdl(reference, addr, refcnt, d, f) | |
4bd8800e TL |
90 | #endif |
91 | ||
d758ad8c TL |
92 | #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ |
93 | defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) | |
4bd8800e TL |
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; | |
e0de25c5 | 104 | extern int rc_history_count; |
4bd8800e | 105 | #endif |