[systemd-devel] [PATCH] Dynamically allocate bootchart logs

Lennart Poettering lennart at poettering.net
Fri May 3 09:42:17 PDT 2013


On Fri, 03.05.13 09:30, Kok, Auke-jan H (auke-jan.h.kok at intel.com) wrote:

> >> The linked list approach drives down this memory requirement and makes
> >> navigating all the data much more straightforward. I also much prefer
> >> head pointers instead of having index numbers around.
> >
> > Still sounds like greedy_realloc() is what you want here. Storing sample
> > data in a dynamically increasing array sounds much more natural than a
> > linked list.
> 
> I admit I hadn't heard of greedy_realloc() unti Zbigniew mentioned it,
> and I still fail to see why it would be so much better other than "you
> can access members by index". You're still doing an allocation each
> time you extend the array (unless you're doing tricks and
> preallocate).

Yes, that's what it does, it reallocates with exponentially increasing
sizes.

The benefit is random access and a you need two pointers less per entry,
which is quite something on 64bit...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list