00001
00057 #include "globals.h"
00058 #include "utils.h"
00059
00060 #ifdef CDP_FOR_SER
00061
00062 #else
00063 unsigned long shm_mem_size = SHM_MEM_SIZE;
00064 int memlog = L_ERR;
00065 int memdbg = L_MEM;
00066 int debug = L_MEM;
00067 int log_facility = 1;
00068 int log_stderr = 1;
00069 int process_no=0;
00070 #endif
00071
00072
00073
00074
00075
00076
00077
00079 int init_memory(int show_status)
00080 {
00081 #ifdef PKG_MALLOC
00082 if (init_pkg_mallocs()==-1)
00083 goto error;
00084 if (show_status){
00085 LOG(memlog, "Memory status (pkg):\n");
00086 pkg_status();
00087 }
00088 #endif
00089
00090 #ifdef SHM_MEM
00091 if (init_shm_mallocs()==-1)
00092 goto error;
00093 if (show_status){
00094 LOG(memlog, "Memory status (shm):\n");
00095 shm_status();
00096 }
00097 #endif
00098 return 1;
00099 error:
00100 return 0;
00101 }
00102
00104 void destroy_memory(int show_status)
00105 {
00106
00107 if (mem_lock)
00108 shm_unlock();
00109
00110
00111 #ifdef SHM_MEM
00112 if (show_status){
00113 LOG(memlog, "Memory status (shm):\n");
00114
00115 shm_sums();
00116 }
00117
00118 shm_mem_destroy();
00119 #endif
00120 #ifdef PKG_MALLOC
00121 if (show_status){
00122 LOG(memlog, "Memory status (pkg):\n");
00123
00124 pkg_sums();
00125 }
00126 #endif
00127 }
00128
00129