[1] https://github.com/freebsd/freebsd/blob/master/sys/sys/tree....
That said, my code does use a couple of macros, but only to do stuff that would be very long-winded and/or impossible without, and using malloc at all is very much frowned upon: storage should either be declared ahead of time in special .var files, or on the stack.
In fact, the environments where C shines oftentimes won't even have a dynamic allocator...
[0] Try allocating ((size_t)-1) bytes. Quite a few implementations will give you a pointer back! They'll add some space for a header, or round up the size to the nearest n-byte boundary. This problem's compounded by the fact people assume passing unsanitized input to malloc effectively sanitizes it.
Magic stuff are for wizards, and most of us are not.
IMHO if you want to become an expert in C and C++, you must be able to read Asm and understand what the machine is actually doing.
A very relevant article on this same idea: http://www.linusakesson.net/programming/kernighans-lever/
I fully agree. Packing data into a binary array, popcount with bit fiddling, macros for generics, etc may seem "magic" to some, but they can be useful especially in performance-critical code. Once you understand these "magic", they are just some common pieces in your toolbox. C is a simple language. Learning C plus such "magic" still takes much less time than grasping the entire C++.
If it's performance, where can I find something like a rationale documentation or empirical measurements of this list implementation?
What a put off!!!
If you are programming in C in the 21st century then you better know what you are doing. And this whole advice is for dilettantes (no offense).
C is no longer a choice language to demonstrate high level programming principles (not that you can't do it but it's not for the lazy), there's a host of other languages that do that better. But if you are interested to reach close to the machine (eg: you program needs a direct view of memory) then C is 'the' choice even today.
Look at the kernel list.h [0], it's a beautiful piece of code, and how concisely it uses macros. So the real advice to those starting out in C is to be bold and get immersed in all the things that people say you should not do and then let simplicity emerge.
In other words, 'simplicity' of the novice and of the experienced share the same word but are two different concepts from two different points of view.
[0]https://github.com/torvalds/linux/blob/master/include/linux/...