diff data-provider.h @ 101:8b90fbba59ef

Fix buffer size in SendMessage macro
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Mon, 08 Apr 2013 16:15:44 +0200
parents 99cbe2b57530
children be87c8e78266
line wrap: on
line diff
--- a/data-provider.h	Tue Mar 26 18:23:46 2013 +0100
+++ b/data-provider.h	Mon Apr 08 16:15:44 2013 +0200
@@ -19,14 +19,16 @@
 };
 
 /* message buffer */
-static char messages[256][16];
+#define DATA_PROVIDER_MSGLEN 256
+#define DATA_PROVIDER_MSGNUM 16
+static char messages[DATA_PROVIDER_MSGLEN][DATA_PROVIDER_MSGNUM];
 static unsigned int messageid = 0;
 
-#define SendMessage(threadId, ...)                                  \
-	do {                                                            \
-		char *message = messages[messageid++ % 16];                 \
-		snprintf(message, sizeof(message), ##__VA_ARGS__);          \
-		PostDeferredCallToThread(MessageCB, message, threadId);     \
+#define SendMessage(threadId, ...)                                     \
+	do {                                                               \
+		char *message = messages[messageid++ % DATA_PROVIDER_MSGNUM];  \
+		snprintf(message, DATA_PROVIDER_MSGLEN - 1, ##__VA_ARGS__);    \
+		PostDeferredCallToThread(MessageCB, message, threadId);        \
 	} while (0)
 
 #endif