]> git.ipfire.org Git - thirdparty/dhcp.git/blob - includes/omapip/alloc.h
4e269f15361b72c1b182ee9812aed518ccd9ae68
[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) 1996-1999 Internet Software Consortium.
7 * Use is subject to license terms which appear in the file named
8 * ISC-LICENSE that should have accompanied this file when you
9 * received it. If a file named ISC-LICENSE did not accompany this
10 * file, or you are not sure the one you have is correct, you may
11 * obtain an applicable copy of the license at:
12 *
13 * http://www.isc.org/isc-license-1.0.html.
14 *
15 * This file is part of the ISC DHCP distribution. The documentation
16 * associated with this file is listed in the file DOCUMENTATION,
17 * included in the top-level directory of this release.
18 *
19 * Support and other services are available for ISC products - see
20 * http://www.isc.org for more information.
21 */
22
23 isc_result_t omapi_buffer_new (omapi_buffer_t **, const char *, int);
24 isc_result_t omapi_buffer_reference (omapi_buffer_t **,
25 omapi_buffer_t *, const char *, int);
26 isc_result_t omapi_buffer_dereference (omapi_buffer_t **, const char *, int);
27
28 #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL)
29 #define DMDOFFSET (sizeof (struct dmalloc_preamble))
30 #define DMLFSIZE 16
31 #define DMUFSIZE 16
32 #define DMDSIZE (DMDOFFSET + DMLFSIZE + DMUFSIZE)
33
34 struct dmalloc_preamble {
35 struct dmalloc_preamble *prev, *next;
36 const char *file;
37 int line;
38 size_t size;
39 unsigned long generation;
40 unsigned char low_fence [DMLFSIZE];
41 };
42 #else
43 #define DMDOFFSET 0
44 #define DMDSIZE 0
45 #endif
46
47 #if defined (DEBUG_RC_HISTORY)
48 #if !defined (RC_HISTORY_MAX)
49 # define RC_HISTORY_MAX 256
50 #endif
51
52 struct rc_history_entry {
53 const char *file;
54 int line;
55 void *reference;
56 void *addr;
57 int refcnt;
58 };
59
60 #define rc_register(x, l, r, y, z) do { \
61 rc_history [rc_history_index].file = (x); \
62 rc_history [rc_history_index].line = (l); \
63 rc_history [rc_history_index].reference = (r); \
64 rc_history [rc_history_index].addr = (y); \
65 rc_history [rc_history_index].refcnt = (z); \
66 if (++rc_history_index == RC_HISTORY_MAX) \
67 rc_history_index = 0;\
68 } while (0)
69 #define rc_register_mdl(r, y, z) \
70 rc_register (__FILE__, __LINE__, r, y, z)
71 #else
72 #define rc_register(file, line, reference, addr, refcnt)
73 #define rc_register_mdl(reference, addr, refcnt)
74 #endif
75
76 #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL)
77 extern struct dmalloc_preamble *dmalloc_list;
78 extern unsigned long dmalloc_outstanding;
79 extern unsigned long dmalloc_longterm;
80 extern unsigned long dmalloc_generation;
81 extern unsigned long dmalloc_cutoff_generation;
82 #endif
83
84 #if defined (DEBUG_RC_HISTORY)
85 extern struct rc_history_entry rc_history [RC_HISTORY_MAX];
86 extern int rc_history_index;
87 #endif