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

Tobias Heider notifications at github.com
Wed Sep 27 19:45:40 CEST 2017


This PR adds a generic block allocator, allowing "dynamic" allocations of structures of the same size in a static memory pool.
It is meant to replace malloc in cases where only fixed size blocks are allocated and freed (see #7615).

### Example usage
```
// Initialize static memory pool "mem" which can hold 3 somestruct_t
MEMARRAY(mem, somestruct_t, 3);

// Initialize mem as a linked list of free elements
memarray_init(&mem);

// Allocate structure
mem = memarray_alloc(&mem);

// Do whatever needs to be done
...

// Free struct
memarray_free(&mem, mem);
```

### Work in Progress
Things to be done:
- Add documentation
- Add unittests
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/7651

-- Commit Summary --

  * sys/memarray: added generic memory block allocator module

-- File Changes --

    M sys/Makefile (3)
    A sys/include/memarray.h (55)
    A sys/memarray/Makefile (1)
    A sys/memarray/memarray.c (39)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/7651.patch
https://github.com/RIOT-OS/RIOT/pull/7651.diff

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


More information about the notifications mailing list