From 80eb0b3ccedc1c35b17fdc1a743a424471591bdc Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 21 Nov 2021 11:11:11 +0500 Subject: [PATCH] Rename destroctor --- src/atoms.c | 5 ++++- src/atoms.h | 8 +++++++- src/dwm.c | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/atoms.c b/src/atoms.c index a7c3da1..94ebe21 100644 --- a/src/atoms.c +++ b/src/atoms.c @@ -28,7 +28,10 @@ Atoms atoms_create(Display *const dpy) return atoms; } -void atoms_destroy(Atoms atoms) +void atoms_delete(Atoms atoms) { + // TODO: maybe we should assert + if (atoms == NULL) return; + free(atoms); } diff --git a/src/atoms.h b/src/atoms.h index 06d1e8d..316b60d 100644 --- a/src/atoms.h +++ b/src/atoms.h @@ -1,8 +1,14 @@ #ifndef _ATOMS_H #define _ATOMS_H +#include #include +#define ATOMS_DELETE(atoms) { \ + atoms_delete(atoms); \ + atoms = NULL; \ +} + /* EWMH atoms */ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, @@ -18,6 +24,6 @@ typedef struct Atoms { } *Atoms; Atoms atoms_create(Display *dpy); -void atoms_destroy(Atoms atoms); +void atoms_delete(Atoms atoms); #endif // _ATOMS_H diff --git a/src/dwm.c b/src/dwm.c index de531b7..e3526b3 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -545,7 +545,7 @@ void cleanup() free(scheme[i]); } - atoms_destroy(atoms); + ATOMS_DELETE(atoms); XDestroyWindow(dpy, wmcheckwin); drw_free(drw); XSync(dpy, False);