ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/ihost/libstatgrab/disk_stat.c
(Generate patch)

Comparing projects/cms/source/ihost/libstatgrab/disk_stat.c (file contents):
Revision 1.4 by pajs, Mon May 13 12:47:15 2002 UTC vs.
Revision 1.6 by pajs, Thu May 16 17:02:43 2002 UTC

# Line 37 | Line 37 | char *get_disk_stats(){
37          system_disks_t *sd_ptr=sd;
38          int counter=0;
39          char *xml_disk_stats;
40 +        char *xml_disk_stats_ptr;
41   #ifdef SOLARIS
42          struct mnttab mp;
43          struct statvfs df;
# Line 90 | Line 91 | char *get_disk_stats(){
91  
92          }
93  
94 +        if((fclose(f))!=0){
95 +                errf("Failed to close mnttab");
96 +                return NULL;
97 +        }
98 +
99   #endif
100   #ifdef linux
101          if ((f=fopen("/etc/mtab", "r" ))==NULL){
# Line 169 | Line 175 | char *get_disk_stats(){
175          xml_disk_stats=strdup("<disk>");
176          
177          while(sd_ptr!=NULL){
178 +                xml_disk_stats_ptr=xml_disk_stats;
179                  if((xml_disk_stats=strf("%s<p%d name=\"%s\" mount=\"%s\" kbytes=\"%ld\" used=\"%ld\" avail=\"%ld\" totalinodes=\"%ld\" freeinodes=\"%ld\"></p%d>", xml_disk_stats, counter, sd_ptr->disk->device_name, sd_ptr->disk->mnt_point, sd_ptr->disk->size, sd_ptr->disk->used, sd_ptr->disk->avail, sd_ptr->disk->t_inodes, sd_ptr->disk->f_inodes, counter)) == NULL){
180                          errf("strf failed (%m)");
181                          return NULL;
182                  }
183 +                free(xml_disk_stats_ptr);
184                  sd_ptr=sd_ptr->next_disk;
185                  counter++;
186          }
187 <
187 >        xml_disk_stats_ptr=xml_disk_stats;
188          xml_disk_stats=strf("%s</disk>",xml_disk_stats);
189 +        free(xml_disk_stats_ptr);      
190 +
191 +        /* Cleaning up */
192 +        sd_ptr=sd;
193 +        while(sd_ptr!=NULL){
194 +                sd=sd_ptr->next_disk;
195 +                free(sd_ptr->disk->device_name);
196 +                free(sd_ptr->disk->mnt_point);
197 +                free(sd_ptr->disk);
198 +                free(sd_ptr);
199 +                sd_ptr=sd;
200 +        }
201  
202          return xml_disk_stats;
203   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines