mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +00:00
Use template for free_and_zero
This commit is contained in:
parent
c51972b5e2
commit
45dfe4994d
@ -31,8 +31,6 @@
|
||||
#ifndef _conky_h_
|
||||
#define _conky_h_
|
||||
|
||||
#define free_and_zero(PTR) do { if(PTR) free(PTR); (PTR) = NULL; } while(0)
|
||||
|
||||
#include <config.h> /* defines */
|
||||
#include "common.h" /* at least for struct dns_data */
|
||||
#include <sys/utsname.h> /* struct uname_s */
|
||||
@ -370,4 +368,11 @@ extern enum x_initialiser_state x_initialised;
|
||||
#define UNUSED(a) (void)a
|
||||
#define UNUSED_ATTR __attribute__ ((unused))
|
||||
|
||||
template <class T> void free_and_zero(T *ptr) {
|
||||
if(ptr) {
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _conky_h_ */
|
||||
|
Loading…
Reference in New Issue
Block a user