Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

dbg_mem.h File Reference

#include <stdlib.h>

Include dependency graph for dbg_mem.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define DEBUG_MALLOC   malloc
#define DEBUG_CALLOC   calloc
#define DEBUG_REALLOC   realloc
#define DEBUG_FREE   free

Functions

void * debug_malloc (const char *file, int line, size_t)
void * debug_calloc (const char *file, int line, size_t, size_t)
void * debug_realloc (const char *file, int line, void *, size_t)
void debug_free (void *)
void disable_debug_memory ()
void enable_debug_memory ()
void clear_dbg_mem_list ()
void print_dbg_mem_list ()

Variables

int log_debug_mem_list
int print_debug_mem_calls
int next_log_debug_id


Define Documentation

#define DEBUG_MALLOC   malloc
 

Definition at line 48 of file dbg_mem.h.

Referenced by CMS_ASCII_UPDATER::CMS_ASCII_UPDATER(), CMS_XDR_UPDATER::CMS_XDR_UPDATER(), LOCMEM::LOCMEM(), NML_QR_SERVER::NML_QR_SERVER(), bbdCreateReaderStruct(), bbdCreateWriterStruct(), NML_SERVER_LOCAL_PORT::blocking_read(), PHYSMEM_HANDLE::clear_memory(), RCS_TIMER::init(), CMS_SERVER::initialize_write_request_space(), PHYSMEM_HANDLE::memsetf(), CMS::open(), NML::operator new(), CMS::operator new(), rcs_sem_create(), rcs_sem_open(), recvline(), recvmsgt_implementation(), sendmsgt(), setTestDMAData(), set_default_nml_config_file(), CMS_XDR_UPDATER::set_encoded_data(), RCS_LINKED_LIST::store_after_current_node(), RCS_LINKED_LIST::store_at_head(), RCS_LINKED_LIST::store_at_tail(), RCS_LINKED_LIST::store_before_current_node(), CMS_XDR_UPDATER::update(), xdr_REMOTE_READ_REPLY(), xdr_REMOTE_READ_REPLY_PASCAL(), xdr_REMOTE_WRITE_REQUEST(), and xdr_REMOTE_WRITE_REQUEST_PASCAL().

#define DEBUG_CALLOC   calloc
 

Definition at line 50 of file dbg_mem.h.

Referenced by rcs_shm_open(), and table_add().

#define DEBUG_REALLOC   realloc
 

Definition at line 51 of file dbg_mem.h.

#define DEBUG_FREE   free
 

Definition at line 53 of file dbg_mem.h.

Referenced by bbdDelete(), bbdDeleteWriterStruct(), NML_SERVER_LOCAL_PORT::blocking_read(), clean_prev_read_info(), convert_print_list_to_lines(), corrected_free(), RCS_LINKED_LIST::delete_current_node(), RCS_LINKED_LIST::delete_node(), RCS_LINKED_LIST::flush_list(), freeDMAInfo(), free_recvmsg_collection_buffer(), free_sendmsg_collection_buffer(), getDMAInfo(), CMS_SERVER::initialize_write_request_space(), NML::operator delete(), CMS::operator delete(), rcs_sem_close(), rcs_sem_create(), rcs_sem_open(), rcs_shm_close(), rcs_shm_delete(), recvline(), recvmsgt_implementation(), RCS_LINKED_LIST::retrieve_head(), RCS_LINKED_LIST::retrieve_tail(), sendmsgt(), CMS_UPDATER::set_encoded_data(), CMS::set_encoded_data(), table_add(), table_delete(), update_lines_table(), CMS::~CMS(), CMS_SERVER::~CMS_SERVER(), NML_QR_SERVER::~NML_QR_SERVER(), and RCS_TIMER::~RCS_TIMER().


Function Documentation

void* debug_malloc const char *    file,
int    line,
size_t    s
 

Definition at line 115 of file dbg_mem.cc.

00116 {
00117   void *ret = malloc (s);
00118   if (log_debug_mem_list)
00119     {
00120       add_dbg_mem_list (file, line, ret, s);
00121     }
00122   if (print_debug_mem_calls)
00123     {
00124       rcs_print ("%p  = malloc(%d)\n", ret, s);
00125     }
00126   return ret;
00127 }

void* debug_calloc const char *    file,
int    line,
size_t    nelem,
size_t    elsize
 

Definition at line 130 of file dbg_mem.cc.

00131 {
00132   void *ret = calloc (nelem, elsize);
00133   if (log_debug_mem_list)
00134     {
00135       add_dbg_mem_list (file, line, ret, nelem * elsize);
00136     }
00137   if (print_debug_mem_calls)
00138     {
00139       rcs_print ("%p  = calloc(%d,%d)\n", ret, nelem, elsize);
00140     }
00141   return ret;
00142 }

void* debug_realloc const char *    file,
int    line,
void *    ptr,
size_t    s
 

Definition at line 145 of file dbg_mem.cc.

00146 {
00147   void *orig_ptr = ptr;
00148   if (log_debug_mem_list)
00149     {
00150       delete_dbg_mem_list (orig_ptr);
00151     }
00152   void *new_ptr = NULL;
00153   new_ptr = realloc (ptr, s);
00154   if (log_debug_mem_list)
00155     {
00156       add_dbg_mem_list (file, line, new_ptr, s);
00157     }
00158   if (print_debug_mem_calls)
00159     {
00160       rcs_print ("%p = realloc(%p,%d)\n", new_ptr, orig_ptr, s);
00161     }
00162   return new_ptr;
00163 }

void debug_free void *    ptr
 

Definition at line 166 of file dbg_mem.cc.

00167 {
00168   if (print_debug_mem_calls)
00169     {
00170       rcs_print ("free(%p)\n", ptr);
00171     }
00172   if (log_debug_mem_list)
00173     {
00174       delete_dbg_mem_list (ptr);
00175     }
00176   if (NULL != ptr)
00177     {
00178       free (ptr);
00179     }
00180 }

void disable_debug_memory  
 

Definition at line 34 of file dbg_mem.cc.

00035 {
00036   log_debug_mem_list = 0;
00037   print_debug_mem_calls = 0;
00038   next_log_debug_id = 0;
00039 }

void enable_debug_memory  
 

Definition at line 26 of file dbg_mem.cc.

00027 {
00028   log_debug_mem_list = 1;
00029   print_debug_mem_calls = 1;
00030   next_log_debug_id = 0;
00031 }

void clear_dbg_mem_list  
 

Definition at line 43 of file dbg_mem.cc.

00044 {
00045   log_debug_mem_list = 0;
00046   next_log_debug_id = 0;
00047   if (NULL != dbg_mem_list)
00048     {
00049       delete dbg_mem_list;
00050       dbg_mem_list = NULL;
00051     }
00052 }

void print_dbg_mem_list  
 

Definition at line 55 of file dbg_mem.cc.

00056 {
00057   if (NULL == dbg_mem_list)
00058     {
00059       rcs_print ("Debug memory list is NULL.\n");
00060       return;
00061     }
00062   rcs_print ("\tAddress \tsize \tid \tFile \tline\n");
00063   DEBUG_MEM_ENTRY *dbg_mem_entry =
00064     (DEBUG_MEM_ENTRY *) dbg_mem_list->get_head ();
00065   while (NULL != dbg_mem_entry)
00066     {
00067       rcs_print ("%p \t%d(0x%X) \t%d \t%s \t%d\n", dbg_mem_entry->address,
00068                  dbg_mem_entry->size, dbg_mem_entry->size, dbg_mem_entry->id,
00069                  dbg_mem_entry->file, dbg_mem_entry->line);
00070       dbg_mem_entry = (DEBUG_MEM_ENTRY *) dbg_mem_list->get_next ();
00071     }
00072 }


Variable Documentation

int log_debug_mem_list
 

Definition at line 29 of file dbg_mem.h.

int print_debug_mem_calls
 

Definition at line 30 of file dbg_mem.h.

int next_log_debug_id
 

Definition at line 31 of file dbg_mem.h.


Generated on Sun Dec 2 15:57:06 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001