News for hackers. Stuff that matters.
Re:Tinyalloc: replacement for malloc/free in unmanaged, line... by felixguendling on Sunday January 06, 2019 @03:08PM (#18840298)
As some comments point out that this code might not be production ready, can anyone recommend other solutions that are able to manage a given block of memory? My understanding of libraries like jemalloc is that they are replacing malloc (using system calls brk and mmap [0]) but I can't hand it an already allocated block of memory to manage, right?

Something like

    memory_manager m(some_buffer);
    allocation a = m.allocate(512);
would be nice. :-)

[0] https://medium.com/iskakaushik/eli5-jemalloc-e9bd412abd70

Re:Tinyalloc: replacement for malloc/free in unmanaged, line... by lfy_google on Sunday January 06, 2019 @04:01PM (#18840687)
https://android.googlesource.com/platform/external/qemu/+/em...

https://android.googlesource.com/platform/external/qemu/+/em...

https://android.googlesource.com/platform/external/qemu/+/em...

These 3 files should be a fairly self contained, minimal way to allocate into existing buffers. No attempt is made at thread safety though (we assume the user synchronizes that themselves)

Re:Tinyalloc: replacement for malloc/free in unmanaged, line... by dividuum on Sunday January 06, 2019 @05:19PM (#18841112)
This TLSF implementation should be able to do that: https://github.com/mattconte/tlsf
Re:Tinyalloc: replacement for malloc/free in unmanaged, line... by nuclx on Sunday January 06, 2019 @11:32PM (#18842765)
FreeRTOS features sone nice and simple allocators on fixed buffers [0]. I have used heap4 to implement memory management for a fully portable test suite requiring malloc. Really any toy allocator would have done the job for that use-case, since performance wasn't critical, but heap4 was fairly easy to integrate.

[0] https://www.freertos.org/a00111.html

Re:Tinyalloc: replacement for malloc/free in unmanaged, line... by davidtgoldblatt on Sunday January 06, 2019 @10:17PM (#18842497)
Depending on what exactly you mean by "hand it a block of memory to manage", you can do this with jemalloc's extent hook functionality. Though that's meant for "I have some long-lived data structures, I want all their memory stored on hugepages" more than "I have this small-ish data structure, I want to batch its allocations together".
Re:Tinyalloc: replacement for malloc/free in unmanaged, line... by ksherlock on Sunday January 06, 2019 @04:10PM (#18840730)