|
|
|
|
|
by pushrax
4190 days ago
|
|
> the prev/next pointer is in the ListNode, not in the object itself, so it's obviously a dereference... The ListNode is embedded in the Point, so their storage is actually combined. The memory layout would be something like 0x0 x
0x4 y
0x8 next
0xc prev
0x10 owner
with the total structure being 20 bytes if pointers are 32-bit.> Aren't ListNode just a way to index a list ? Isn't this Point2D just "marked" to be on a certain list ? The list itself is formed entirely by the ListNodes themselves. There is no backing array to index into; the storage for points (and nodes, which are contained in points) is created with an individual malloc per point. The way you reference a list is by holding a reference to the head, which is just a regular ListNode. |
|