/[monit]/monit/gc.c
ViewVC logotype

Diff of /monit/gc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by hauk, Thu Aug 29 22:51:45 2002 UTC revision 1.8 by hauk, Fri Sep 6 17:26:32 2002 UTC
# Line 27  Line 27 
27    
28    
29  /* Private prototypes */  /* Private prototypes */
30  static void _gcpl(Process_T);  static void _gcpl(Process_T*);
31  static void _gcppl(Port_T);  static void _gcppl(Port_T*);
32  static void _gcpcl(Checksum_T);  static void _gcpcl(Checksum_T*);
33  static void _gcprl(Mail_T);  static void _gcpql(Resource_T*);
34  static void _gcpql(Resource_T q);  static void _gcppil(ProcInfo_T*);
35  static void _gcppil(ProcInfo_T pi);  
36    
37  /**  /**
38   *  Release allocated memory.   *  Release allocated memory.
# Line 51  static void _gcppil(ProcInfo_T pi); Line 51  static void _gcppil(ProcInfo_T pi);
51  void gc() {  void gc() {
52    
53    gc_protocols();    gc_protocols();
54    if(processlist) _gcpl(processlist);    if(processlist) _gcpl(&processlist);
55    if(mygroup) free(mygroup);    if(mygroup) free(mygroup);
56        
57  }  }
58    
59    
60  void gc_process(Process_T p) {  void gc_process(Process_T *p) {
61    
62    int i;    int i;
63        
64    if ( p->portlist ) {    if((*p)->portlist) {
65            
66      _gcppl(p->portlist);      _gcppl(&(*p)->portlist);
67    
68    }    }
69    
70    if ( p->checksumlist ) {    if((*p)->checksumlist) {
71            
72      _gcpcl(p->checksumlist);      _gcpcl(&(*p)->checksumlist);
73    
74    }    }
75    
76    if ( p->maillist ) {    if((*p)->maillist) {
77    
78        _gcprl(p->maillist);      gc_mail_list(&(*p)->maillist);
79    
80    }    }
81    
82    if ( p->resourcelist ) {    if((*p)->resourcelist) {
83        
84        _gcpql(p->resourcelist);      _gcpql(&(*p)->resourcelist);
85        
86    }    }
87    
88    if ( p->procinfo ) {    if((*p)->procinfo) {
89    
90        _gcppil(p->procinfo);      _gcppil(&(*p)->procinfo);
91    
92    }    }
93        
94    free(p->name);    free((*p)->name);
95    free(p->pidfile);    free((*p)->pidfile);
96    free(p->group);    free((*p)->group);
97    if(p->start) {    if((*p)->start) {
98      for(i= 0; p->start->arg[i]; i++)      for(i= 0; (*p)->start->arg[i]; i++)
99          free(p->start->arg[i]);          free((*p)->start->arg[i]);
100      free(p->start);      free((*p)->start);
101    }    }
102    if(p->stop) {    if((*p)->stop) {
103      for(i= 0; p->stop->arg[i]; i++)      for(i= 0; (*p)->stop->arg[i]; i++)
104          free(p->stop->arg[i]);          free((*p)->stop->arg[i]);
105      free(p->stop);      free((*p)->stop);
106    }    }
107    p->next= NULL;    (*p)->next= NULL;
108    free(p);    free(*p);
109    
110  }  }
111        
112    
113    void gc_mail_list(Mail_T *m) {
114      
115      if((*m)->next)
116          gc_mail_list(&(*m)->next);
117      
118      free((*m)->to);
119      free((*m)->from);
120      free((*m)->subject);
121      free((*m)->message);
122      free((*m)->opt_message);
123      free(*m);
124      *m= NULL;
125      
126    }
127    
128        
129  /* ----------------------------------------------------------------- Private */  /* ----------------------------------------------------------------- Private */
130    
131    
132  static void _gcpl(Process_T p) {  static void _gcpl(Process_T *p) {
133        
134    if ( p->next ) {    if((*p)->next) {
135            
136      _gcpl(p->next);      _gcpl(&(*p)->next);
137            
138    }    }
139        
140    gc_process(p);    gc_process(&(*p));
141    p= NULL;    *p= NULL;
142            
143  }  }
144    
145    
146  static void _gcppl(Port_T p) {  static void _gcppl(Port_T *p) {
147        
148    if ( p->next ) {    if((*p)->next) {
149            
150      _gcppl(p->next);      _gcppl(&(*p)->next);
151            
152    }    }
153    
154    free(p->hostname);    free((*p)->hostname);
155    free(p->request);    free((*p)->request);
156    free(p);    free(*p);
157    p= NULL;    *p= NULL;
158    
159  }  }
160    
161    
162  static void _gcpcl(Checksum_T p) {  static void _gcpcl(Checksum_T *p) {
163        
164    if ( p->next ) {    if((*p)->next) {
165            
166      _gcpcl(p->next);      _gcpcl(&(*p)->next);
167            
168    }    }
169    
170    free(p->file);    free((*p)->file);
171    free(p->md5);    free((*p)->md5);
172    free(p);    free(*p);
173    p= NULL;    *p= NULL;
174    
175  }  }
176    
177    
178  static void _gcprl(Mail_T p) {  static void _gcpql(Resource_T *q) {
179    
180    if ( p->next ) {    if((*q)->next) {
181    
182      _gcprl(p->next);      _gcpql(&(*q)->next);
183    
184    }    }
185    
186    free(p->to);    free(*q);
187    free(p->from);    *q= NULL;
   free(p->subject);  
   free(p->message);  
   free(p);  
   p= NULL;  
   
 }  
   
 static void _gcpql(Resource_T q) {  
   
   if ( q->next ) {  
   
     _gcpql(q->next);  
   
   }  
188        
   
   free(q);  
   q= NULL;  
189  }  }
190    
 static void _gcppil(ProcInfo_T pi) {  
191    
192    free(pi);  static void _gcppil(ProcInfo_T *pi) {
193    pi= NULL;  
194      free(*pi);
195      *pi= NULL;
196    
197  }  }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26