34#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
35 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
43#if defined (DEBUG_RC_HISTORY)
49#if defined (DEBUG_RC_HISTORY)
53static int dmalloc_failures;
54static char out_of_memory[] =
"Run out of memory.";
61#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
62 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
75 if (dmalloc_failures > 10) {
82 }
else if (dmalloc_failures >= 10) {
91#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
92 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
111 (&foo [
i + size])) % 143) + 113;
112#if defined (DEBUG_MALLOC_POOL_EXHAUSTIVELY)
120 log_error (
"malloc fence modified: %s(%d)",
125 foo = (
unsigned char *)
dp;
127 if (foo [
i +
dp -> size] !=
129 (&foo [
i +
dp -> size])) % 143) + 113) {
130 log_error (
"malloc fence modified: %s(%d)",
138#ifdef DEBUG_REFCNT_DMALLOC_FREE
150#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
151 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
153 unsigned char *
bar = ptr;
162 log_error (
"%s(%d): freeing unknown memory: %lx",
167 dp -> prev -> next =
dp -> next;
169 dp -> next -> prev =
dp -> prev;
182 log_error (
"malloc fence modified: %s(%d)",
188 if (
bar [
i +
dp -> size] !=
190 (&
bar [
i +
dp -> size])) % 143) + 113) {
191 log_error (
"malloc fence modified: %s(%d)",
199#ifdef DEBUG_REFCNT_DMALLOC_FREE
206#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
207 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
234 dp -> prev -> next =
dp -> next;
236 dp -> next -> prev =
dp -> prev;
268#if defined(DEBUG_MALLOC_POOL)
278#if defined (DEBUG_MALLOC_POOL)
284 log_error (
"malloc fence modified: %s(%d)",
289 foo = (
unsigned char *)
dp;
291 if (foo [
i +
dp -> size] !=
293 (&foo [
i +
dp -> size])) % 143) + 113) {
294 log_error (
"malloc fence modified: %s(%d)",
300#if defined (DEBUG_MEMORY_LEAKAGE) || \
301 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
305#if defined (DEBUG_RC_HISTORY)
346#if defined (DEBUG_RC_HISTORY)
349 log_info (
" referenced by %s(%d)[%lx]: addr = %lx refcnt = %x",
382#if defined (RC_HISTORY_COMPRESSION)
383 int i,
j = 0,
m,
n = 0;
431#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
432 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
476 log_error (
"no space for memory usage summary.");
489 cp [
i + 1].count = 1;
508#if defined(DUMP_RC_HISTORY)
524 if (type -> allocator) {
526 status = (*type -> allocator) (&foo,
file,
line);
527 tsize = type -> size;
535 tsize = (*type -> sizer) (size);
537 tsize = type -> size;
566 if (type -> initialize)
579#if defined (POINTER_DEBUG)
580 log_error (
"%s(%d): reference store into non-null pointer!",
606#if defined (POINTER_DEBUG)
614 if ((*h) -> refcnt <= 0) {
615#if defined (POINTER_DEBUG)
616 log_error (
"%s(%d): dereference of pointer with refcnt of zero!",
618#if defined (DEBUG_RC_HISTORY)
631 if ((*h) ->
inner && (*h) ->
inner -> outer &&
632 h != &((*h) ->
inner -> outer))
636 if ((*h) -> outer && (*h) -> outer ->
inner &&
637 h != &((*h) -> outer ->
inner))
655 if ((*h) -> refcnt ==
671 for (
p = (*h) -> outer;
674 if (
p -> outer &&
p -> outer ->
inner ==
p)
696 0, 1,
hp -> type -> rc_flag);
704 if (
hp -> type -> destroy)
706 if (
hp -> type -> freer)
714 h, *h, (*h) -> refcnt, 1,
715 (*h) -> type -> rc_flag);
721 (*h) -> type -> rc_flag);
740 (*h) -> head =
sizeof ((*h) -> buf) - 1;
752#if defined (POINTER_DEBUG)
753 log_error (
"%s(%d): reference store into non-null pointer!",
773#if defined (POINTER_DEBUG)
781 if ((*h) -> refcnt <= 0) {
782#if defined (POINTER_DEBUG)
783 log_error (
"%s(%d): dereference of pointer with refcnt of zero!",
785#if defined (DEBUG_RC_HISTORY)
797 if ((*h) -> refcnt == 0)
857 new -> u.integer = intval;
860 memcpy (
new -> u.buffer.value,
s, val);
861 new -> u.buffer.len = val;
864 new -> u.buffer.len = val;
888#if defined (POINTER_DEBUG)
908#if defined (POINTER_DEBUG)
916 if ((*h) -> refcnt <= 0) {
917#if defined (POINTER_DEBUG)
918 log_error (
"%s(%d): dereference of pointer with refcnt of zero!",
920#if defined (DEBUG_RC_HISTORY)
932 if ((*h) -> refcnt <= 0 ) {
933 switch ((*h) -> type) {
975#if defined (POINTER_DEBUG)
995#if defined (POINTER_DEBUG)
1003 if ((*h) -> refcnt <= 0) {
1004#if defined (POINTER_DEBUG)
1005 log_error (
"%s(%d): dereference of pointer with refcnt of zero!",
1007#if defined (DEBUG_RC_HISTORY)
1019 if ((*h) -> refcnt <= 0 ) {
1034 memset (
new, 0,
sizeof *
new);
1046#if defined (POINTER_DEBUG)
1047 log_error (
"%s(%d): reference store into non-null pointer!",
1067#if defined (POINTER_DEBUG)
1075 if ((*h) -> refcnt <= 0) {
1076#if defined (POINTER_DEBUG)
1077 log_error (
"%s(%d): dereference of pointer with refcnt of zero!",
1079#if defined (DEBUG_RC_HISTORY)
1091 if ((*h) -> refcnt == 0) {
1115 new -> count = count;
1128#if defined (POINTER_DEBUG)
1129 log_error (
"%s(%d): reference store into non-null pointer!",
1149#if defined (POINTER_DEBUG)
1157 if ((*h) -> refcnt <= 0) {
1158#if defined (POINTER_DEBUG)
1159 log_error (
"%s(%d): dereference of pointer with zero refcnt!",
1161#if defined (DEBUG_RC_HISTORY)
1173 if ((*h) -> refcnt <= 0 ) {
#define rc_register(file, line, reference, addr, refcnt, d, f)
isc_result_t omapi_typed_data_new(const char *file, int line, omapi_typed_data_t **t, omapi_datatype_t type,...)
isc_result_t omapi_object_reference(omapi_object_t **r, omapi_object_t *h, const char *file, int line)
isc_result_t omapi_value_new(omapi_value_t **d, const char *file, int line)
isc_result_t omapi_value_dereference(omapi_value_t **h, const char *file, int line)
isc_result_t omapi_data_string_reference(omapi_data_string_t **r, omapi_data_string_t *h, const char *file, int line)
isc_result_t omapi_addr_list_new(omapi_addr_list_t **d, unsigned count, const char *file, int line)
isc_result_t omapi_typed_data_dereference(omapi_typed_data_t **h, const char *file, int line)
isc_result_t omapi_data_string_new(omapi_data_string_t **d, unsigned len, const char *file, int line)
isc_result_t omapi_data_string_dereference(omapi_data_string_t **h, const char *file, int line)
isc_result_t omapi_typed_data_reference(omapi_typed_data_t **r, omapi_typed_data_t *h, const char *file, int line)
isc_result_t omapi_value_reference(omapi_value_t **r, omapi_value_t *h, const char *file, int line)
isc_result_t omapi_buffer_dereference(omapi_buffer_t **h, const char *file, int line)
isc_result_t omapi_object_allocate(omapi_object_t **o, omapi_object_type_t *type, size_t size, const char *file, int line)
isc_result_t omapi_buffer_new(omapi_buffer_t **h, const char *file, int line)
isc_result_t omapi_addr_list_reference(omapi_addr_list_t **r, omapi_addr_list_t *h, const char *file, int line)
isc_result_t omapi_object_initialize(omapi_object_t *o, omapi_object_type_t *type, size_t usize, size_t psize, const char *file, int line)
isc_result_t omapi_buffer_reference(omapi_buffer_t **r, omapi_buffer_t *h, const char *file, int line)
isc_result_t omapi_addr_list_dereference(omapi_addr_list_t **h, const char *file, int line)
void omapi_print_dmalloc_usage_by_caller(void)
isc_result_t omapi_object_dereference(omapi_object_t **, const char *, int)
#define OMAPI_TYPED_DATA_INT_LEN
#define dmalloc_reuse(x, y, l, z)
void * dmalloc(size_t, const char *, int)
void dfree(void *, const char *, int)
#define OMAPI_TYPED_DATA_OBJECT_LEN
#define OMAPI_DATA_STRING_EMPTY_SIZE
#define OMAPI_TYPED_DATA_NOBUFFER_LEN
int log_error(const char *,...) __attribute__((__format__(__printf__
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
isc_result_t omapi_handle_clear(omapi_handle_t)
int int log_info(const char *,...) __attribute__((__format__(__printf__
#define DHCP_R_INVALIDARG