summaryrefslogtreecommitdiff
path: root/die.c
diff options
context:
space:
mode:
Diffstat (limited to 'die.c')
-rw-r--r--die.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/die.c b/die.c
new file mode 100644
index 0000000..4c0014d
--- /dev/null
+++ b/die.c
@@ -0,0 +1,31 @@
+/*
+ * Subject to the GPL, version 2.
+ */
+
+#include "xmalloc.h"
+
+struct panic_func {
+ void *arg;
+ void (*on_panic)(void *arg);
+ struct panic_func *next;
+};
+
+static struct panic_func *panic_funcs;
+
+void panic_func_add(void (*on_panic)(void *arg), void *arg)
+{
+ struct panic_func *handler = xmallocz(sizeof(*handler));
+
+ handler->arg = arg;
+ handler->on_panic = on_panic;
+ handler->next = panic_funcs;
+ panic_funcs = handler;
+};
+
+void call_on_panic_funcs(void)
+{
+ struct panic_func *it;
+
+ for (it = panic_funcs; it; it = it->next)
+ it->on_panic(it->arg);
+}