[riot-notifications] [RIOT-OS/RIOT] Generic memory block allocator (#7651)

Kaspar Schleiser notifications at github.com
Fri Apr 6 17:07:19 CEST 2018


kaspar030 requested changes on this pull request.



> @@ -0,0 +1,18 @@
+Expected result
+===============
+
+This application should run a number of tests equal to NUMBER_OF_TESTS (Default 12).
+
+At the beginning of the tests memory usage of each thread is printed.
+At the end of the tests, the threads memory usage is printed once more time.
+
+This test is passed if the memory used by the main thread remains static.
+
+Background
+==========
+
+The module `memarray` is the static memory allocator for RIOT-OS

IMO this needs re-phrasing. What is a "static memory allocator"?

> +
+#define ENABLE_DEBUG    (0)
+#include "debug.h"
+
+void memarray_init(memarray_t *mem, void *data, size_t size, size_t num)
+{
+    assert((mem != NULL) && (data != NULL) && (size >= sizeof(void *)));
+
+    DEBUG("memarray: Initialize memarray of %u times %u Bytes at %p\n",
+          (unsigned)num, (unsigned)size, data);
+
+    mem->free_data = data;
+    mem->size = size;
+    mem->num = num;
+
+    for (size_t i = 0; i < (mem->num - 1); i++) {

This makes ```mem->num - 1``` re-evaluate on every loop iteration.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/7651#pullrequestreview-110099092
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20180406/63dde1cc/attachment.html>


More information about the notifications mailing list