riot-boards.h: helper macro for memarray initialization

The pre-processor macro MEMARRAY helps declaring and initializing the
buffer and memarray_t structure that are required by memarray_init().

Change-Id: I9f9732881469d7163c5710b3ffd0e46d86a9fb66
diff --git a/crypto.c b/crypto.c
index dcb7752..a71e457 100644
--- a/crypto.c
+++ b/crypto.c
@@ -118,8 +118,6 @@
 }
 
 #elif defined (RIOT_VERSION)
-
-#include "memarray.h"
 MEMARRAY(handshake_storage, dtls_handshake_parameters_t, DTLS_HANDSHAKE_MAX)
 MEMARRAY(security_storage,  dtls_security_parameters_t, DTLS_SECURITY_MAX)
 
diff --git a/dtls.c b/dtls.c
index f640a0c..938722e 100644
--- a/dtls.c
+++ b/dtls.c
@@ -62,7 +62,6 @@
 #define DTLS10_VERSION 0xfeff
 
 #ifdef RIOT_VERSION
-#include "memarray.h"
 MEMARRAY(dtlscontext_storage, dtls_context_t, DTLS_CONTEXT_MAX)
 #endif /* RIOT_VERSION */
 
diff --git a/netq.c b/netq.c
index 22ffc10..bcee04f 100644
--- a/netq.c
+++ b/netq.c
@@ -62,8 +62,6 @@
 }
 
 #elif defined (RIOT_VERSION)
-
-#include "memarray.h"
 MEMARRAY(netq_storage, netq_t, NETQ_MAXCNT)
 
 static inline netq_t *
diff --git a/peer.c b/peer.c
index c9a1be4..6a56473 100644
--- a/peer.c
+++ b/peer.c
@@ -60,8 +60,6 @@
 }
 
 #elif defined (RIOT_VERSION)
-
-#include "memarray.h"
 MEMARRAY(peer_storage, dtls_peer_t, DTLS_PEER_MAX)
 
 void
diff --git a/platform-specific/riot_boards.h b/platform-specific/riot_boards.h
index e8b21a4..284c000 100644
--- a/platform-specific/riot_boards.h
+++ b/platform-specific/riot_boards.h
@@ -149,5 +149,16 @@
 #  endif
 #endif
 
+/* The memarray API requires declaration of the following structures
+ * over and over, so we define a macro for a cleaner API:
+ */
+#include "memarray.h"
+#define MEMARRAY(name, structure, cnt)                   \
+  structure name ## _data[cnt];                          \
+  memarray_t name = {                                    \
+    .free_data = name ## _data,                          \
+    .size = sizeof(structure),                           \
+    .num = cnt                                           \
+  };
 
 #endif /* _RIOT_BOARDS_H_ */