00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024
00025 #include "monitor.h"
00026 #include "protocol.h"
00027 #include "ssl.h"
00028
00029
00030
00031 static void _gcppl(Port_T*);
00032 static void _gcpl(Process_T*);
00033 static void _gcpcl(Checksum_T*);
00034 static void _gcpql(Resource_T*);
00035 static void _gcppil(ProcInfo_T*);
00036 static void _gcptl(Timestamp_T*);
00037 static void _gcpdl(Dependant_T *d);
00038
00039
00052
00053
00054
00055 void gc() {
00056
00057 gc_protocols();
00058 if(processlist) _gcpl(&processlist);
00059 if(Run.mygroup) free(Run.mygroup);
00060
00061 }
00062
00063
00064 void gc_process(Process_T *p) {
00065
00066 int i;
00067
00068 ASSERT(p);
00069
00070 if((*p)->portlist) {
00071
00072 _gcppl(&(*p)->portlist);
00073
00074 }
00075
00076 if((*p)->checksumlist) {
00077
00078 _gcpcl(&(*p)->checksumlist);
00079
00080 }
00081
00082 if((*p)->maillist) {
00083
00084 gc_mail_list(&(*p)->maillist);
00085
00086 }
00087
00088 if((*p)->resourcelist) {
00089
00090 _gcpql(&(*p)->resourcelist);
00091
00092 }
00093
00094 if((*p)->procinfo) {
00095
00096 _gcppil(&(*p)->procinfo);
00097
00098 }
00099
00100 if((*p)->timestamplist) {
00101
00102 _gcptl(&(*p)->timestamplist);
00103
00104 }
00105
00106 if((*p)->dependantlist) {
00107
00108 _gcpdl(&(*p)->dependantlist);
00109
00110 }
00111
00112 free((*p)->name);
00113 free((*p)->pidfile);
00114 free((*p)->group);
00115 if((*p)->start) {
00116 for(i= 0; (*p)->start->arg[i]; i++)
00117 free((*p)->start->arg[i]);
00118 free((*p)->start);
00119 }
00120 if((*p)->stop) {
00121 for(i= 0; (*p)->stop->arg[i]; i++)
00122 free((*p)->stop->arg[i]);
00123 free((*p)->stop);
00124 }
00125 (*p)->next= NULL;
00126 free(*p);
00127
00128 }
00129
00130
00131 void gc_mail_list(Mail_T *m) {
00132
00133 ASSERT(m);
00134
00135 if((*m)->next)
00136 gc_mail_list(&(*m)->next);
00137
00138 free((*m)->to);
00139 free((*m)->from);
00140 free((*m)->subject);
00141 free((*m)->message);
00142 free((*m)->opt_message);
00143 free(*m);
00144 *m= NULL;
00145
00146 }
00147
00148
00149
00150
00151
00152 static void _gcpl(Process_T *p) {
00153
00154 ASSERT(p);
00155
00156 if((*p)->next) {
00157
00158 _gcpl(&(*p)->next);
00159
00160 }
00161
00162 gc_process(&(*p));
00163 *p= NULL;
00164
00165 }
00166
00167
00168 static void _gcppl(Port_T *p) {
00169
00170 ASSERT(p);
00171
00172 if((*p)->next) {
00173
00174 _gcppl(&(*p)->next);
00175
00176 }
00177
00178 free((*p)->hostname);
00179 free((*p)->request);
00180 delete_ssl_socket((*p)->ssl);
00181 free(*p);
00182 *p= NULL;
00183
00184 }
00185
00186
00187 static void _gcpcl(Checksum_T *p) {
00188
00189 ASSERT(p);
00190
00191 if((*p)->next) {
00192
00193 _gcpcl(&(*p)->next);
00194
00195 }
00196
00197 free((*p)->file);
00198 free((*p)->md5);
00199 free(*p);
00200 *p= NULL;
00201
00202 }
00203
00204
00205 static void _gcpql(Resource_T *q) {
00206
00207 ASSERT(q);
00208
00209 if((*q)->next) {
00210
00211 _gcpql(&(*q)->next);
00212
00213 }
00214
00215 free(*q);
00216 *q= NULL;
00217
00218 }
00219
00220
00221 static void _gcppil(ProcInfo_T *pi) {
00222
00223 ASSERT(pi);
00224
00225 free(*pi);
00226 *pi= NULL;
00227
00228 }
00229
00230
00231 static void _gcptl(Timestamp_T *p) {
00232
00233 ASSERT(p);
00234
00235 if((*p)->next) {
00236
00237 _gcptl(&(*p)->next);
00238
00239 }
00240
00241 free((*p)->pathname);
00242 free(*p);
00243 *p= NULL;
00244
00245 }
00246
00247
00248 static void _gcpdl(Dependant_T *d) {
00249
00250 ASSERT(d);
00251
00252 if((*d)->next) {
00253
00254 _gcpdl(&(*d)->next);
00255
00256 }
00257
00258 free((*d)->dependant);
00259 free(*d);
00260 *d= NULL;
00261
00262 }