summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-25 21:17:09 -0400
committerPietro Gagliardi <[email protected]>2014-08-25 21:17:09 -0400
commit35dcac92d644c5ec03b9e4b2f01debec05f99e1c (patch)
tree1db165cdfc5170fa05abdd8dd0244b38d73c4d6d
parenta952cfcc58e7657daa2f4e6861b257ab06d8e8c6 (diff)
Improved modalqueue.c error handling. A bit dirty to have the same function in multiple Go files like this, but meh.
-rw-r--r--redo/modalqueue.c6
-rw-r--r--redo/modalqueue.h1
-rw-r--r--redo/uitask_darwin.go5
-rw-r--r--redo/uitask_unix.go5
-rw-r--r--redo/uitask_windows.go5
5 files changed, 20 insertions, 2 deletions
diff --git a/redo/modalqueue.c b/redo/modalqueue.c
index 7474c95..a41787f 100644
--- a/redo/modalqueue.c
+++ b/redo/modalqueue.c
@@ -1,6 +1,8 @@
// 19 august 2014
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
#include "modalqueue.h"
static struct {
@@ -17,7 +19,7 @@ void beginModal(void)
mq.cap = 128;
mq.queue = (void **) malloc(mq.cap * sizeof (void *));
if (mq.queue == NULL)
- abort();//TODO
+ modalPanic("error allocating modal queue", strerror(errno));
mq.len = 0;
}
}
@@ -42,7 +44,7 @@ int queueIfModal(void *what)
mq.cap *= 2;
mq.queue = (void **) realloc(mq.queue, mq.cap * sizeof (void *));
if (mq.queue == NULL)
- abort();//TODO
+ modalPanic("error growing modal queue", strerror(errno));
}
return 1;
}
diff --git a/redo/modalqueue.h b/redo/modalqueue.h
index 912ba32..e05db36 100644
--- a/redo/modalqueue.h
+++ b/redo/modalqueue.h
@@ -6,3 +6,4 @@ extern int queueIfModal(void *);
/* needed by the above */
extern void doissue(void *);
+extern void modalPanic(char *, char *);
diff --git a/redo/uitask_darwin.go b/redo/uitask_darwin.go
index 13de8e0..2e0380a 100644
--- a/redo/uitask_darwin.go
+++ b/redo/uitask_darwin.go
@@ -39,3 +39,8 @@ func issue(f *func()) {
func doissue(fp unsafe.Pointer) {
perform(fp)
}
+
+//export modalPanic
+func modalPanic(reason *C.char, strerror *C.char) {
+ panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror)))
+}
diff --git a/redo/uitask_unix.go b/redo/uitask_unix.go
index 86628dd..7786d95 100644
--- a/redo/uitask_unix.go
+++ b/redo/uitask_unix.go
@@ -53,3 +53,8 @@ func doissue(data unsafe.Pointer) {
// for the modal queue functions
perform(data)
}
+
+//export modalPanic
+func modalPanic(reason *C.char, strerror *C.char) {
+ panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror)))
+}
diff --git a/redo/uitask_windows.go b/redo/uitask_windows.go
index c3c1884..5d9d29a 100644
--- a/redo/uitask_windows.go
+++ b/redo/uitask_windows.go
@@ -68,3 +68,8 @@ func makemsgwin() error {
func doissue(fp unsafe.Pointer) {
perform(fp)
}
+
+//export modalPanic
+func modalPanic(reason *C.char, strerror *C.char) {
+ panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror)))
+}