includes/omapip/alloc.h

Go to the documentation of this file.
00001 /* alloc.h
00002 
00003    Definitions for the object management API protocol memory allocation... */
00004 
00005 /*
00006  * Copyright (c) 2004,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
00007  * Copyright (c) 1996-2003 by Internet Software Consortium
00008  *
00009  * Permission to use, copy, modify, and distribute this software for any
00010  * purpose with or without fee is hereby granted, provided that the above
00011  * copyright notice and this permission notice appear in all copies.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
00014  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00015  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
00016  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00017  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00018  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
00019  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00020  *
00021  *   Internet Systems Consortium, Inc.
00022  *   950 Charter Street
00023  *   Redwood City, CA 94063
00024  *   <info@isc.org>
00025  *   https://www.isc.org/
00026  *
00027  */
00028 
00029 isc_result_t omapi_buffer_new (omapi_buffer_t **, const char *, int);
00030 isc_result_t omapi_buffer_reference (omapi_buffer_t **,
00031                                      omapi_buffer_t *, const char *, int);
00032 isc_result_t omapi_buffer_dereference (omapi_buffer_t **, const char *, int);
00033 
00034 #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
00035                 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
00036 #define DMDOFFSET (sizeof (struct dmalloc_preamble))
00037 #define DMLFSIZE 16
00038 #define DMUFSIZE 16
00039 #define DMDSIZE (DMDOFFSET + DMLFSIZE + DMUFSIZE)
00040 
00041 struct dmalloc_preamble {
00042         struct dmalloc_preamble *prev, *next;
00043         const char *file;
00044         int line;
00045         size_t size;
00046         unsigned long generation;
00047         unsigned char low_fence [DMLFSIZE];
00048 };
00049 #else
00050 #define DMDOFFSET 0
00051 #define DMDSIZE 0
00052 #endif
00053 
00054 /* rc_history flags... */
00055 #define RC_LEASE        1
00056 #define RC_MISC         2
00057 
00058 #if defined (DEBUG_RC_HISTORY)
00059 #if !defined (RC_HISTORY_MAX)
00060 # define RC_HISTORY_MAX 256
00061 #endif
00062 
00063 #if !defined (RC_HISTORY_FLAGS)
00064 # define RC_HISTORY_FLAGS (RC_LEASE | RC_MISC)
00065 #endif
00066 
00067 struct rc_history_entry {
00068         const char *file;
00069         int line;
00070         void *reference;
00071         void *addr;
00072         int refcnt;
00073 };
00074 
00075 #define rc_register(x, l, r, y, z, d, f) do { \
00076                 if (RC_HISTORY_FLAGS & ~(f)) { \
00077                         rc_history [rc_history_index].file = (x); \
00078                         rc_history [rc_history_index].line = (l); \
00079                         rc_history [rc_history_index].reference = (r); \
00080                         rc_history [rc_history_index].addr = (y); \
00081                         rc_history [rc_history_index].refcnt = (z); \
00082                         rc_history_next (d); \
00083                 } \
00084         } while (0)
00085 #define rc_register_mdl(r, y, z, d, f) \
00086         rc_register (__FILE__, __LINE__, r, y, z, d, f)
00087 #else
00088 #define rc_register(file, line, reference, addr, refcnt, d, f)
00089 #define rc_register_mdl(reference, addr, refcnt, d, f)
00090 #endif
00091 
00092 #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
00093                 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
00094 extern struct dmalloc_preamble *dmalloc_list;
00095 extern unsigned long dmalloc_outstanding;
00096 extern unsigned long dmalloc_longterm;
00097 extern unsigned long dmalloc_generation;
00098 extern unsigned long dmalloc_cutoff_generation;
00099 #endif
00100 
00101 #if defined (DEBUG_RC_HISTORY)
00102 extern struct rc_history_entry rc_history [RC_HISTORY_MAX];
00103 extern int rc_history_index;
00104 extern int rc_history_count;
00105 #endif

Generated on 5 Apr 2014 for ISC DHCP by  doxygen 1.6.1