Removed libnotif_get_info() as it was just a bunch of race conditions
2 files changed, 8 insertions(+), 20 deletions(-)

M inc/notify.h
M src/notify.c
M inc/notify.h +3 -1
@@ 18,10 18,12 @@ 
 #ifndef NOTIFY_H
 #define NOTIFY_H
 
+#include <stdint.h>
+
 void libnotif_init(void);
 
 char** libnotif_get_info(void);
 
-void libnotif_register_cb(void (*cb)(const char* app_name, const char* summary, const char* body));
+void libnotif_register_cb(void (*cb)(uint32_t id, const char* app_name, const char* summary, const char* body));
 
 #endif

          
M src/notify.c +5 -19
@@ 19,7 19,6 @@ 
 
 #include <errno.h>
 #include <stdio.h>
-#include <stdint.h>
 #include <unistd.h>
 #include <stdbool.h>
 #include <inttypes.h>

          
@@ 29,9 28,8 @@ 
 #include <gio/gio.h>
 
 static bool running = false;
-static char* notif_data[5];
 static uint32_t id;
-static void (*callback)(const char* app_name, const char* summary, const char* body) = NULL;
+static void (*callback)(uint32_t id, const char* app_name, const char* summary, const char* body) = NULL;
 
 static void dbus_method_call(GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer data) {
 	(void) sender;

          
@@ 47,18 45,10 @@ static void dbus_method_call(GDBusConnec
 		int32_t expire_timeout;
 		g_variant_get(parameters, "(&su&s&s&sasa{sv}i)", &app_name, &replaces_id, &app_icon, &summary, &body, &actions, &hints, &expire_timeout);
 		g_variant_iter_free(actions);
-		for(size_t count = 0; notif_data[count] != NULL; ++count) {
-			free(notif_data[count]);
-		}
-		char* id_str = malloc(11);
-		snprintf(id_str, 11, "%" PRIu32, ++id);
-		notif_data[0] = id_str;
-		notif_data[1] = strdup(app_name);
-		notif_data[2] = strdup(summary);
-		notif_data[3] = strdup(body);
-		notif_data[4] = NULL;
+
+		++id;
 		if(callback != NULL) {
-			callback(app_name, summary, body);
+			callback(id, app_name, summary, body);
 		}
 		GVariant* ret = g_variant_new("(u)", id);
 		g_dbus_method_invocation_return_value(invocation, ret);

          
@@ 371,10 361,6 @@ void libnotif_init(void) {
 	}
 }
 
-char** libnotif_get_info(void) {
-	return notif_data;
-}
-
-void libnotif_register_cb(void (*cb)(const char* app_name, const char* summary, const char* body)) {
+void libnotif_register_cb(void (*cb)(uint32_t id, const char* app_name, const char* summary, const char* body)) {
 	callback = cb;
 }