summaryrefslogtreecommitdiffstats
path: root/xrescheck.h
diff options
context:
space:
mode:
authorRichard Grenville <[email protected]>2014-08-03 19:40:40 +0800
committerRichard Grenville <[email protected]>2014-08-03 19:40:40 +0800
commitebab3dc5061e58da34eed227e8f98965bdd1bc30 (patch)
tree61e81f85f8af76d7a982d183660200e2e036e6c2 /xrescheck.h
parent66b420aa62d28af6f6e7b064f58db446829b4f6a (diff)
downloadtdebase-ebab3dc5061e58da34eed227e8f98965bdd1bc30.tar.gz
tdebase-ebab3dc5061e58da34eed227e8f98965bdd1bc30.zip
Bug fix: Fix X pixmap leakage in shadow_paint
- Fix X pixmap leakage in shadow_paint. - Add the skeleton of a X resource leakage checker.
Diffstat (limited to 'xrescheck.h')
-rw-r--r--xrescheck.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/xrescheck.h b/xrescheck.h
new file mode 100644
index 000000000..48f254b20
--- /dev/null
+++ b/xrescheck.h
@@ -0,0 +1,70 @@
+#ifndef COMPTON_XRESCHECK_H
+#define COMPTON_XRESCHECK_H
+
+#include "common.h"
+#include <uthash.h>
+
+typedef struct {
+ XID xid;
+ const char *type;
+ const char *file;
+ const char *func;
+ int line;
+ UT_hash_handle hh;
+} xrc_xid_record_t;
+
+#define M_POS_DATA_PARAMS const char *file, int line, const char *func
+#define M_POS_DATA_PASSTHROUGH file, line, func
+#define M_POS_DATA __FILE__, __LINE__, __func__
+
+void
+xrc_add_xid_(XID xid, const char *type, M_POS_DATA_PARAMS);
+
+#define xrc_add_xid(xid, type) xrc_add_xid_(xid, type, M_POS_DATA)
+
+void
+xrc_delete_xid_(XID xid, M_POS_DATA_PARAMS);
+
+#define xrc_delete_xid(xid) xrc_delete_xid_(xid, M_POS_DATA)
+
+void
+xrc_report_xid(void);
+
+void
+xrc_clear_xid(void);
+
+// Pixmap
+
+static inline Pixmap
+XCreatePixmap_(Display *dpy, Drawable drawable,
+ unsigned int width, unsigned int height, unsigned int depth,
+ M_POS_DATA_PARAMS) {
+ Pixmap ret = XCreatePixmap(dpy, drawable, width, height, depth);
+ if (ret)
+ xrc_add_xid_(ret, "Pixmap", M_POS_DATA_PASSTHROUGH);
+ return ret;
+}
+
+#define XCreatePixmap(dpy, drawable, width, height, depth) \
+ XCreatePixmap_(dpy, drawable, width, height, depth, M_POS_DATA)
+
+static inline Pixmap
+XCompositeNameWindowPixmap_(Display *dpy, Window window, M_POS_DATA_PARAMS) {
+ Pixmap ret = XCompositeNameWindowPixmap(dpy, window);
+ if (ret)
+ xrc_add_xid_(ret, "PixmapC", M_POS_DATA_PASSTHROUGH);
+ return ret;
+}
+
+#define XCompositeNameWindowPixmap(dpy, window) \
+ XCompositeNameWindowPixmap_(dpy, window, M_POS_DATA)
+
+static inline void
+XFreePixmap_(Display *dpy, Pixmap pixmap, M_POS_DATA_PARAMS) {
+ XFreePixmap(dpy, pixmap);
+ xrc_delete_xid_(pixmap, M_POS_DATA_PASSTHROUGH);
+}
+
+#define XFreePixmap(dpy, pixmap) XFreePixmap_(dpy, pixmap, M_POS_DATA);
+
+#endif