chiark / gitweb /
further horrid memory debugging stuff
[disorder] / disobedience / disobedience.h
index a63cf44e56510dda9e6a4e360c03a8ad6ef27aa1..21d589dac74d1a4b5878e30a55e5198c969277f3 100644 (file)
@@ -167,6 +167,35 @@ GtkWidget *choose_widget(void);
 void choose_update(void);
 /* Called when we think the choose tree might need updating */
 
+/* Widget leakage debugging rubbish ---------------------------------------- */
+
+#if MDEBUG
+#define NW(what) do {                                   \
+  if(++current##what % 100 > max##what) {               \
+    fprintf(stderr, "%s:%d: %d %s\n",                   \
+            __FILE__, __LINE__, current##what, #what);  \
+    max##what = current##what;                          \
+  }                                                     \
+} while(0)
+#define WT(what) static int current##what, max##what
+#define DW(what) (--current##what)
+#else
+#define NW(what) do { } while(0)
+#define DW(what) do { } while(0)
+#define WT(what) struct neverused
+#endif
+
+#if MTRACK
+extern const char *mtag;
+#define MTAG(x) do { mtag = x; } while(0)
+#define MTAG_PUSH(x) do { const char *save_mtag = mtag; mtag = x; (void)0
+#define MTAG_POP() mtag = save_mtag; } while(0)
+#else
+#define MTAG(x) do { } while(0)
+#define MTAG_PUSH(x) do {} while(0)
+#define MTAG_POP() do {} while(0)
+#endif
+
 #endif /* DISOBEDIENCE_H */
 
 /*
@@ -177,4 +206,3 @@ fill-column:79
 indent-tabs-mode:nil
 End:
 */
-/* arch-tag:5DbN8e67AvkhPmNqSQyZFQ */