This is the mail archive of the
mailing list for the glibc project.
Re: Linked List Implementation
On 27/11/17 16:22, Florian Weimer wrote:
On 11/27/2017 01:19 PM, Toebs Douglass wrote:
I'd love to find some new ideas, things I've totally missed, use cases
I had no idea about.
There's some disagreement whether inline allocation of keys/values needs
to be supported,
Inline? do you mean by this inside the data structure function calls?
whether key/value pointers should be void *,
What are the alternatives?
and whether the allocator should be tied to malloc/free.
If the user handles allocation, this problem is solved, because it is up
to the user.
As it is, NUMA alone makes allocation inside a data structure ugly,
because you have to pass in so many parameters.
In general though the user benefit hugely from being able to allocate
from the stack or heap, or globals; when I stopped doing allocation
inside data structures, it seemed to me absolutely clearly the right
thing to do - resource allocation is a different and separate task.
Some people prefer
macros which generate function definitions,
Hard to follow in a debugger. Code should look like it is.
others prefer function
pointers (sometimes with a closure argument, sometimes without).
Do you mean function pointers for the API functions? stored in say the
are strictly opposed to aliasing violations which happen to work today,
others want strict language conformance.
I'm not sure I've ever run into aliasing issues... why would you benefit
from doing so / what would you be doing for it to occur anyway?
For individual data structures, the level of configuration offered
varies greatly. Not everyone things a custom resize policy is necessary
for arrays or hash tables, or you need to be able to choose between
different conflict resolution strategies in hash tables.
Yes, but this doesn't matter - data structures in what they offer, as
opposed to how they are implemented (macros, allocation, etc), vary. A
list is not a tree. It's fine to have many different data structures
which offer different things.
Some people want C++ compatibility, others are strictly opposed to it.
I've heard of "Clean C", which can be compiled in C++ mode, where the
compiler can optimize more thoroughly. That seems nice.
Those are just he issues that come to my mind immediately.
I've clearly been living under the stairs for a long time :-)