mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
Fix memleak in is_disk()
This commit is contained in:
parent
1b90218c33
commit
47965eedbc
@ -298,6 +298,9 @@ static void print_version(void)
|
||||
<< " * Imlib2\n"
|
||||
#endif /* BUILD_LUA_IMLIB2 */
|
||||
#endif /* BUILD_LUA */
|
||||
#ifdef DEBUG
|
||||
<< " * Debugging extensions\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
@ -4498,6 +4501,8 @@ int main(int argc, char **argv)
|
||||
curl_global_cleanup();
|
||||
#endif
|
||||
|
||||
disk_cleanup();
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
kvm_close(kd);
|
||||
#endif
|
||||
|
@ -63,6 +63,7 @@ struct diskio_stat {
|
||||
extern struct diskio_stat stats;
|
||||
|
||||
struct diskio_stat *prepare_diskio_stat(const char *);
|
||||
void disk_cleanup(void);
|
||||
int update_diskio(void);
|
||||
void clear_diskio_stats(void);
|
||||
void update_diskio_values(struct diskio_stat *, unsigned int, unsigned int);
|
||||
|
15
src/linux.cc
15
src/linux.cc
@ -2291,12 +2291,25 @@ typedef struct DEV_LIST_TYPE
|
||||
|
||||
} DEV_LIST, *DEV_LIST_PTR;
|
||||
|
||||
DEV_LIST_PTR dev_head = NULL;
|
||||
|
||||
void disk_cleanup() {
|
||||
DEV_LIST_PTR dev_next, dev_cur = dev_head;
|
||||
|
||||
while(dev_cur) {
|
||||
dev_next = dev_cur->next;
|
||||
free(dev_cur->dev_name);
|
||||
free(dev_cur);
|
||||
dev_cur = dev_next;
|
||||
}
|
||||
dev_head = NULL;
|
||||
}
|
||||
|
||||
/* Same as sf #2942117 but memoized using a linked list */
|
||||
int is_disk(char *dev)
|
||||
{
|
||||
char syspath[PATH_MAX];
|
||||
char *slash;
|
||||
static DEV_LIST_PTR dev_head = NULL;
|
||||
DEV_LIST_PTR dev_cur, dev_last;
|
||||
|
||||
dev_cur = dev_head;
|
||||
|
Loading…
Reference in New Issue
Block a user