A declarative challenge

I noticed a quite stupid use of double mallocation in my list node code which's not actually effective in several ways. I used a dynamically allocated arrays for storing the links inside a struct, which should normally be static. So if you malloc the entry itself and the links, you don't really need to cause a single allocation can do both things. The problem is that you'll need to self-reference cause a link links to a collections of links. Without starting an identifier that encapsulates the array and thus newly begun pointer type, it won't work. One solution I had in mind was the most direct and simple one: just malloc an array and access it's members. But for that you'd need to pointer-cast back and forth... No optimal and far away from declarative. However, it seems the only possibility and may work efficient when tested and used carefully.

Oh, how I love the "dangers" of those bare metal programmings! It's the point where your inner nerd can show how a clean mind can stay above the course of all restriction-induced matters.

No comments: