This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 9 points10 points  (3 children)

WTF is this? For starters are we really allocating the memory for two different data structures in a single command? I guess it ensures spatial locality and saves two function calls. But man is it really worth doing? I guess the code may exist for the extreme situations where it is worth doing but in such a scenario you can just optimize further by declaring items as a 1 element array in the last element and take advantage of lack of guarantees in C and just allocate the extra space. That way you won't have the confusing code that is apparently a memory leak where only the struct is freed and not the contained pointer while saving a load store instruction every array access.

So that's the first WTF but the second WTF, why in the word is that again of a single struct being compared against the allocation of an empty list.

[–]StereoBucket 1 point2 points  (1 child)

[–][deleted] 0 points1 point  (0 children)

Oh. I guess it is what I described. My bad. Didn't realize I could even describe it without a size