1: /* alloc.h
2:
3: Definitions for the object management API protocol memory allocation... */
4:
5: /*
6: * Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
7: * Copyright (c) 1996-2003 by Internet Software Consortium
8: *
9: * Permission to use, copy, modify, and distribute this software for any
10: * purpose with or without fee is hereby granted, provided that the above
11: * copyright notice and this permission notice appear in all copies.
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: * 950 Charter Street
23: * Redwood City, CA 94063
24: * <info@isc.org>
25: * https://www.isc.org/
26: *
27: * This software has been written for Internet Systems Consortium
28: * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
29: * To learn more about Internet Systems Consortium, see
30: * ``https://www.isc.org/''. To learn more about Vixie Enterprises,
31: * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
32: * ``http://www.nominum.com''.
33: */
34:
35: isc_result_t omapi_buffer_new (omapi_buffer_t **, const char *, int);
36: isc_result_t omapi_buffer_reference (omapi_buffer_t **,
37: omapi_buffer_t *, const char *, int);
38: isc_result_t omapi_buffer_dereference (omapi_buffer_t **, const char *, int);
39:
40: #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
41: defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
42: #define DMDOFFSET (sizeof (struct dmalloc_preamble))
43: #define DMLFSIZE 16
44: #define DMUFSIZE 16
45: #define DMDSIZE (DMDOFFSET + DMLFSIZE + DMUFSIZE)
46:
47: struct dmalloc_preamble {
48: struct dmalloc_preamble *prev, *next;
49: const char *file;
50: int line;
51: size_t size;
52: unsigned long generation;
53: unsigned char low_fence [DMLFSIZE];
54: };
55: #else
56: #define DMDOFFSET 0
57: #define DMDSIZE 0
58: #endif
59:
60: /* rc_history flags... */
61: #define RC_LEASE 1
62: #define RC_MISC 2
63:
64: #if defined (DEBUG_RC_HISTORY)
65: #if !defined (RC_HISTORY_MAX)
66: # define RC_HISTORY_MAX 256
67: #endif
68:
69: #if !defined (RC_HISTORY_FLAGS)
70: # define RC_HISTORY_FLAGS (RC_LEASE | RC_MISC)
71: #endif
72:
73: struct rc_history_entry {
74: const char *file;
75: int line;
76: void *reference;
77: void *addr;
78: int refcnt;
79: };
80:
81: #define rc_register(x, l, r, y, z, d, f) do { \
82: if (RC_HISTORY_FLAGS & ~(f)) { \
83: rc_history [rc_history_index].file = (x); \
84: rc_history [rc_history_index].line = (l); \
85: rc_history [rc_history_index].reference = (r); \
86: rc_history [rc_history_index].addr = (y); \
87: rc_history [rc_history_index].refcnt = (z); \
88: rc_history_next (d); \
89: } \
90: } while (0)
91: #define rc_register_mdl(r, y, z, d, f) \
92: rc_register (__FILE__, __LINE__, r, y, z, d, f)
93: #else
94: #define rc_register(file, line, reference, addr, refcnt, d, f)
95: #define rc_register_mdl(reference, addr, refcnt, d, f)
96: #endif
97:
98: #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
99: defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
100: extern struct dmalloc_preamble *dmalloc_list;
101: extern unsigned long dmalloc_outstanding;
102: extern unsigned long dmalloc_longterm;
103: extern unsigned long dmalloc_generation;
104: extern unsigned long dmalloc_cutoff_generation;
105: #endif
106:
107: #if defined (DEBUG_RC_HISTORY)
108: extern struct rc_history_entry rc_history [RC_HISTORY_MAX];
109: extern int rc_history_index;
110: extern int rc_history_count;
111: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>