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

Kaspar Schleiser notifications at github.com
Thu Sep 28 11:53:37 CEST 2017


kaspar030 requested changes on this pull request.



> +        return NULL;
+    }
+    void *free = mem->first_free;
+    mem->first_free = *((void **)mem->first_free);
+    return free;
+}
+
+void memarray_init(memarray_t *mem)
+{
+    for (size_t i = 0; i < mem->count - 1; i++) {
+        void *next = ((char *)mem->data) + ((i + 1) * mem->size);
+        memcpy(((char *)mem->data) + (i * mem->size), &next, sizeof(void *));
+    }
+}
+
+uint8_t memarray_free(memarray_t *mem, void *ptr)

This looks like O(n) free. There must be another way.

-- 
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-65787251
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20170928/4b46444d/attachment.html>


More information about the notifications mailing list