summaryrefslogtreecommitdiff
path: root/libvxi11client/perlbits
diff options
context:
space:
mode:
Diffstat (limited to 'libvxi11client/perlbits')
-rw-r--r--libvxi11client/perlbits/perlglue.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/libvxi11client/perlbits/perlglue.c b/libvxi11client/perlbits/perlglue.c
index 259a652..5c6448b 100644
--- a/libvxi11client/perlbits/perlglue.c
+++ b/libvxi11client/perlbits/perlglue.c
@@ -12,13 +12,13 @@
static GAsyncQueue* interruptqueue;
typedef struct {
- char* handle;
+ gchar* handle;
} Event;
static Event* lastevent = NULL;
+// perl is responsible for freeing the handle
static void freeevent(Event* event) {
- g_free(event->handle);
g_free(event);
}
@@ -29,11 +29,9 @@ static void freelast() {
}
}
-static void interruptcallback(char* handle) {
+static void interruptcallback(gchar* handle) {
Event* event = g_malloc(sizeof(Event));
- int handlelen = strlen(handle);
- event->handle = g_malloc(handlelen + 1);
- strcpy(event->handle, handle);
+ event->handle = handle;
g_async_queue_push(interruptqueue, event);
}
@@ -76,11 +74,12 @@ char* glue_wait_for_interrupt(unsigned int timeout) {
// if we have a timeout pop with a time out
// otherwise block until an interrupt happens
+ freelast();
+
if (timeout > 0) {
GTimeVal whentotimeout;
g_get_current_time(&whentotimeout);
g_time_val_add(&whentotimeout, timeout * 1000);
- freelast();
lastevent = (Event*) g_async_queue_timed_pop(interruptqueue, &whentotimeout);
}
else {