1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

hddtemp: convert to callbacks.free

This commit is contained in:
Phil Sutter 2009-11-08 04:18:19 +01:00
parent eb612dfcb0
commit 9247d838c3
3 changed files with 8 additions and 11 deletions

View File

@ -1267,6 +1267,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
END OBJ(hddtemp, &update_hddtemp) END OBJ(hddtemp, &update_hddtemp)
if (arg) if (arg)
obj->data.s = strndup(arg, text_buffer_size); obj->data.s = strndup(arg, text_buffer_size);
obj->callbacks.free = &free_hddtemp;
#endif /* HDDTEMP */ #endif /* HDDTEMP */
#ifdef TCP_PORT_MONITOR #ifdef TCP_PORT_MONITOR
END OBJ_ARG(tcp_portmon, &tcp_portmon_update, "tcp_portmon: needs arguments") END OBJ_ARG(tcp_portmon, &tcp_portmon_update, "tcp_portmon: needs arguments")
@ -1748,15 +1749,6 @@ void free_text_objects(struct text_object *root, int internal)
free_top(obj, internal); free_top(obj, internal);
break; break;
#endif /* __linux__ */ #endif /* __linux__ */
#ifdef HDDTEMP
case OBJ_hddtemp:
if (data.s) {
free(data.s);
data.s = NULL;
}
free_hddtemp();
break;
#endif /* HDDTEMP */
case OBJ_user_names: case OBJ_user_names:
if (info.users.names) { if (info.users.names) {
free(info.users.names); free(info.users.names);

View File

@ -30,6 +30,7 @@
#include "conky.h" #include "conky.h"
#include "logging.h" #include "logging.h"
#include "text_object.h"
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -223,7 +224,7 @@ void update_hddtemp(void) {
free(data); free(data);
} }
void free_hddtemp(void) void free_hddtemp(struct text_object *obj)
{ {
free_hddtemp_info(); free_hddtemp_info();
if (hddtemp_host) { if (hddtemp_host) {
@ -234,6 +235,10 @@ void free_hddtemp(void)
free(hddtemp_port); free(hddtemp_port);
hddtemp_port = NULL; hddtemp_port = NULL;
} }
if (obj->data.s) {
free(obj->data.s);
obj->data.s = NULL;
}
} }
int get_hddtemp_info(const char *dev, short *val, char *unit) int get_hddtemp_info(const char *dev, short *val, char *unit)

View File

@ -6,7 +6,7 @@
void set_hddtemp_host(const char *); void set_hddtemp_host(const char *);
void set_hddtemp_port(const char *); void set_hddtemp_port(const char *);
void update_hddtemp(void); void update_hddtemp(void);
void free_hddtemp(void); void free_hddtemp(struct text_object *);
int get_hddtemp_info(const char *, short *, char *); int get_hddtemp_info(const char *, short *, char *);
#endif /*HDDTEMP_H_*/ #endif /*HDDTEMP_H_*/